Model/AccessCriteria.ps1

#
# Identity Security Cloud API - SOD Violations
# 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

A named set of conflicting access items that together define one side of a separation-of-duties conflict.

.PARAMETER Name
The name of the access criteria grouping.
.PARAMETER ConflictingItems
The list of access items that make up this side of the conflict.
.OUTPUTS

AccessCriteria<PSCustomObject>
#>


function Initialize-AccessCriteria {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${ConflictingItems}
    )

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

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

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

        if ($ConflictingItems.length -lt 1) {
            throw "invalid value for 'ConflictingItems', number of items must be greater than or equal to 1."
        }


        $PSO = [PSCustomObject]@{
            "name" = ${Name}
            "conflictingItems" = ${ConflictingItems}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to AccessCriteria<PSCustomObject>

.DESCRIPTION

Convert from JSON to AccessCriteria<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AccessCriteria<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in AccessCriteria
        $AllProperties = ("name", "conflictingItems")
        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 'name' missing."
        }

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

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

        $PSO = [PSCustomObject]@{
            "name" = ${Name}
            "conflictingItems" = ${ConflictingItems}
        }

        return $PSO
    }

}