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

Attributes related to an IdentityNow ETS event

.PARAMETER Id
The unique ID of the trigger
.PARAMETER VarFilter
JSON path expression that will limit which events the trigger will fire on. When the trigger's `mode` is `basic`, this must match the expression compiled from `filterDefinition`.
.PARAMETER FilterDefinition
No description available.
.PARAMETER Description
Description of the event trigger
.PARAMETER AttributeToFilter
For the `sp:form-submitted` trigger, the name of the form element to filter on. Use it with `operatorValue` and `attributeValue`. For other event triggers this is a legacy field from the earlier trigger filter picker; use `filterDefinition` with `mode` set to `basic` instead. Create and update requests that set this field for the `idn:identity-attributes-changed` or `idn:identity-created` trigger are rejected.
.PARAMETER OperatorValue
For the `sp:form-submitted` trigger, the operator that compares the `attributeToFilter` form element with `attributeValue`, such as `StringEquals`, `StringContains`, `StringStartsWith`, `NumericGreaterThan`, `BooleanEquals` or `ArrayAnyOf`. Create and update requests that set this field for the `idn:identity-created` trigger are rejected.
.PARAMETER AttributeValue
For the `sp:form-submitted` trigger, the value the `attributeToFilter` form element is compared with. For `ArrayAnyOf`, use a list such as `['HR', 'IT']`. Create and update requests that set this field for the `idn:identity-created` trigger are rejected.
.PARAMETER FormDefinitionId
For the `sp:form-submitted` trigger, the ID of the form whose submission starts the workflow. Required when `filter.$` is not set. When `filter.$` is not set, the trigger filter is built from this ID, narrowed by `attributeToFilter`, `operatorValue` and `attributeValue` when all three are set.
.OUTPUTS

EventAttributes<PSCustomObject>
#>


function Initialize-EventAttributes {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${VarFilter},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${FilterDefinition},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${AttributeToFilter},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OperatorValue},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${AttributeValue},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${FormDefinitionId}
    )

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "filter.$" = ${VarFilter}
            "filterDefinition" = ${FilterDefinition}
            "description" = ${Description}
            "attributeToFilter" = ${AttributeToFilter}
            "operatorValue" = ${OperatorValue}
            "attributeValue" = ${AttributeValue}
            "formDefinitionId" = ${FormDefinitionId}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to EventAttributes<PSCustomObject>

.DESCRIPTION

Convert from JSON to EventAttributes<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

EventAttributes<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in EventAttributes
        $AllProperties = ("id", "filter.$", "filterDefinition", "description", "attributeToFilter", "operatorValue", "attributeValue", "formDefinitionId")
        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 "filter.$"))) { #optional property not found
            $VarFilter = $null
        } else {
            $VarFilter = $JsonParameters.PSobject.Properties["filter.$"].value
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "filter.$" = ${VarFilter}
            "filterDefinition" = ${FilterDefinition}
            "description" = ${Description}
            "attributeToFilter" = ${AttributeToFilter}
            "operatorValue" = ${OperatorValue}
            "attributeValue" = ${AttributeValue}
            "formDefinitionId" = ${FormDefinitionId}
        }

        return $PSO
    }

}