Model/MachineIdentityOwnersV2.ps1

#
# Identity Security Cloud API - Machine Identities
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
# Version: v1
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

Owner configuration for a machine identity. A single primary (human IDENTITY) owner plus additional owners that are either up to ten human (IDENTITY) references or exactly one GOVERNANCE_GROUP reference - not both.

.PARAMETER Primary
No description available.
.PARAMETER Secondary
Additional owners. Entries are either up to ten human (IDENTITY) references or exactly one GOVERNANCE_GROUP reference - not both. Governance-group owners appear here with type GOVERNANCE_GROUP.
.OUTPUTS

MachineIdentityOwnersV2<PSCustomObject>
#>


function Initialize-MachineIdentityOwnersV2 {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Primary},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Secondary}
    )

    Process {
        'Creating PSCustomObject: PSSailpoint.MachineIdentities => MachineIdentityOwnersV2' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if (!$Secondary -and $Secondary.length -gt 10) {
            throw "invalid value for 'Secondary', number of items must be less than or equal to 10."
        }


        $PSO = [PSCustomObject]@{
            "primary" = ${Primary}
            "secondary" = ${Secondary}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to MachineIdentityOwnersV2<PSCustomObject>

.DESCRIPTION

Convert from JSON to MachineIdentityOwnersV2<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

MachineIdentityOwnersV2<PSCustomObject>
#>

function ConvertFrom-JsonToMachineIdentityOwnersV2 {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: PSSailpoint.MachineIdentities => MachineIdentityOwnersV2' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in MachineIdentityOwnersV2
        $AllProperties = ("primary", "secondary")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "primary"))) { #optional property not found
            $Primary = $null
        } else {
            $Primary = $JsonParameters.PSobject.Properties["primary"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "secondary"))) { #optional property not found
            $Secondary = $null
        } else {
            $Secondary = $JsonParameters.PSobject.Properties["secondary"].value
        }

        $PSO = [PSCustomObject]@{
            "primary" = ${Primary}
            "secondary" = ${Secondary}
        }

        return $PSO
    }

}