Model/EventAttributesFilterDefinition.ps1

#
# SailPoint Identity Security API - Workflows
# 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

Basic-mode filter that `filter.$` is compiled from. Required when the trigger's `mode` is `basic`, and must be omitted otherwise.

.PARAMETER Path
Collection in the event payload that the conditions are applied to, such as `changes` or `accountRequests`. Use `$` to apply the conditions to the root of the payload.
.PARAMETER Logic
How the conditions are combined. Defaults to `and` when omitted.
.PARAMETER Conditions
Conditions evaluated against each item in `path`.
.OUTPUTS

EventAttributesFilterDefinition<PSCustomObject>
#>


function Initialize-EventAttributesFilterDefinition {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Path},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("and", "or")]
        [String]
        ${Logic},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Conditions}
    )

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "path" = ${Path}
            "logic" = ${Logic}
            "conditions" = ${Conditions}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to EventAttributesFilterDefinition<PSCustomObject>

.DESCRIPTION

Convert from JSON to EventAttributesFilterDefinition<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

EventAttributesFilterDefinition<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

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

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

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

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

        $PSO = [PSCustomObject]@{
            "path" = ${Path}
            "logic" = ${Logic}
            "conditions" = ${Conditions}
        }

        return $PSO
    }

}