Model/Correlationconfig.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

An ownership correlation config scoped to a source resource. Configs are of type OWNER_PRIMARY or OWNER_SECONDARY and drive how machine identity owners are correlated.

.PARAMETER Id
System-generated unique ID of the correlation config.
.PARAMETER SourceId
The source ID this config belongs to.
.PARAMETER ResourceId
The source resource identifier for this config scope.
.PARAMETER Type
The correlation config type.
.PARAMETER Attributes
JSON object of config attributes. May include syncPrimaryToMachineAccounts (boolean) on OWNER_PRIMARY only.
.PARAMETER Rules
The ordered set of correlation rules for this config.
.OUTPUTS

Correlationconfig<PSCustomObject>
#>


function Initialize-Correlationconfig {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SourceId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ResourceId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("OWNER_PRIMARY", "OWNER_SECONDARY")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${Attributes},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Rules}
    )

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

        if (!$Id) {
            throw "invalid value for 'Id', 'Id' cannot be null."
        }

        if (!$SourceId) {
            throw "invalid value for 'SourceId', 'SourceId' cannot be null."
        }

        if (!$ResourceId) {
            throw "invalid value for 'ResourceId', 'ResourceId' cannot be null."
        }

        if (!$Type) {
            throw "invalid value for 'Type', 'Type' cannot be null."
        }

        if (!$Attributes) {
            throw "invalid value for 'Attributes', 'Attributes' cannot be null."
        }

        if (!$Rules) {
            throw "invalid value for 'Rules', 'Rules' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "sourceId" = ${SourceId}
            "resourceId" = ${ResourceId}
            "type" = ${Type}
            "attributes" = ${Attributes}
            "rules" = ${Rules}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Correlationconfig<PSCustomObject>

.DESCRIPTION

Convert from JSON to Correlationconfig<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Correlationconfig<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Correlationconfig
        $AllProperties = ("id", "sourceId", "resourceId", "type", "attributes", "rules", "created", "modified")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'id' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) {
            throw "Error! JSON cannot be serialized due to the required property 'id' missing."
        } else {
            $Id = $JsonParameters.PSobject.Properties["id"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "sourceId"))) {
            throw "Error! JSON cannot be serialized due to the required property 'sourceId' missing."
        } else {
            $SourceId = $JsonParameters.PSobject.Properties["sourceId"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "resourceId"))) {
            throw "Error! JSON cannot be serialized due to the required property 'resourceId' missing."
        } else {
            $ResourceId = $JsonParameters.PSobject.Properties["resourceId"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "type"))) {
            throw "Error! JSON cannot be serialized due to the required property 'type' missing."
        } else {
            $Type = $JsonParameters.PSobject.Properties["type"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "attributes"))) {
            throw "Error! JSON cannot be serialized due to the required property 'attributes' missing."
        } else {
            $Attributes = $JsonParameters.PSobject.Properties["attributes"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "rules"))) {
            throw "Error! JSON cannot be serialized due to the required property 'rules' missing."
        } else {
            $Rules = $JsonParameters.PSobject.Properties["rules"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "sourceId" = ${SourceId}
            "resourceId" = ${ResourceId}
            "type" = ${Type}
            "attributes" = ${Attributes}
            "rules" = ${Rules}
            "created" = ${Created}
            "modified" = ${Modified}
        }

        return $PSO
    }

}