machine-accounts/src/PSSailpoint.MachineAccounts/Model/MachineAccountV2AllOfOwners.ps1

#
# SailPoint Identity Security API - Machine Accounts
# Use these APIs to interact with the SailPoint Identity Security 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

The owners of the machine account: a primary owner plus secondary owners, which are either up to ten identities or one governance group.

.PARAMETER Primary
The identity selected as the primary owner.
.PARAMETER Secondary
The secondary owners. Entries are either up to ten identities (type `IDENTITY`) or one governance group (type `GOVERNANCE_GROUP`), not both.
.OUTPUTS

MachineAccountV2AllOfOwners<PSCustomObject>
#>


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

    Process {
        'Creating PSCustomObject: PSSailpoint.MachineAccounts => MachineAccountV2AllOfOwners' | 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 MachineAccountV2AllOfOwners<PSCustomObject>

.DESCRIPTION

Convert from JSON to MachineAccountV2AllOfOwners<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

MachineAccountV2AllOfOwners<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in MachineAccountV2AllOfOwners
        $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
    }

}