Model/Criteria.ps1

#
# Identity Security Cloud API - Next Generation Certification Campaigns
# 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

No description available.

.PARAMETER CriteriaType
No description available.
.PARAMETER Operation
No description available.
.PARAMETER CriteriaProperty
The specified key from the Type of criteria.
.PARAMETER CriteriaValue
The value for the specified key from the Type of Criteria. Used for scalar operations. Must be absent when operation is IN.
.PARAMETER CriteriaValues
List of values for the IN operation. Required when operation is IN; must be absent for all other operations.
.PARAMETER Children
List of child criteria. Applicable only for COMPOSITE criteriaType
.OUTPUTS

Criteria<PSCustomObject>
#>


function Initialize-Criteria {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("COMPOSITE", "ROLE", "IDENTITY", "IDENTITY_ATTRIBUTE", "ENTITLEMENT", "ACCESS_PROFILE", "SOURCE", "ACCOUNT", "ACCOUNT_ATTRIBUTE", "IDENTITY_PROFILE", "APP", "ACCESS")]
        [PSCustomObject]
        ${CriteriaType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("EQUALS", "NOT_EQUALS", "CONTAINS", "STARTS_WITH", "ENDS_WITH", "IN", "AND", "OR")]
        [PSCustomObject]
        ${Operation},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CriteriaProperty},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CriteriaValue},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${CriteriaValues},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Children}
    )

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

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

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


        $PSO = [PSCustomObject]@{
            "criteriaType" = ${CriteriaType}
            "operation" = ${Operation}
            "criteriaProperty" = ${CriteriaProperty}
            "criteriaValue" = ${CriteriaValue}
            "criteriaValues" = ${CriteriaValues}
            "children" = ${Children}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Criteria<PSCustomObject>

.DESCRIPTION

Convert from JSON to Criteria<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Criteria<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Criteria
        $AllProperties = ("criteriaType", "operation", "criteriaProperty", "criteriaValue", "criteriaValues", "children")
        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 'criteriaType' missing."
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "criteriaType" = ${CriteriaType}
            "operation" = ${Operation}
            "criteriaProperty" = ${CriteriaProperty}
            "criteriaValue" = ${CriteriaValue}
            "criteriaValues" = ${CriteriaValues}
            "children" = ${Children}
        }

        return $PSO
    }

}