reminder-escalations/src/PSSailpoint.ReminderEscalations/Model/Reminderescalationtrigger.ps1

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

When an escalation fires. `triggerType` selects which fields apply. * `ON_CRON` requires `cron` and exactly one of `beforeDeadLine` or `activeAfter`. `maxFirings` is optional. * `AFTER_REMINDER_COUNT` requires `count` and `delay`. The ruleset must also contain at least one reminder.

.PARAMETER TriggerType
How this escalation decides when to fire.
.PARAMETER Cron
Five-field cron expression. Required when `triggerType` is `ON_CRON`.
.PARAMETER BeforeDeadLine
ISO-8601 duration relative to the deadline. Used when `triggerType` is `ON_CRON`. Mutually exclusive with `activeAfter`.
.PARAMETER ActiveAfter
ISO-8601 duration relative to workflow start. Used when `triggerType` is `ON_CRON`. Mutually exclusive with `beforeDeadLine`.
.PARAMETER MaxFirings
Maximum number of times an `ON_CRON` escalation fires. Null means no cap.
.PARAMETER Count
Reminder count for the current assignee. Required when `triggerType` is `AFTER_REMINDER_COUNT`. Null when `triggerType` is `ON_CRON`.
.PARAMETER Delay
ISO-8601 grace period before an `AFTER_REMINDER_COUNT` escalation fires.
.OUTPUTS

Reminderescalationtrigger<PSCustomObject>
#>


function Initialize-Reminderescalationtrigger {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ON_CRON", "AFTER_REMINDER_COUNT")]
        [String]
        ${TriggerType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Cron} = "",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${BeforeDeadLine} = "",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActiveAfter} = "",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MaxFirings},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Count},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Delay} = ""
    )

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

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

        if ($MaxFirings -and $MaxFirings -lt 1) {
          throw "invalid value for 'MaxFirings', must be greater than or equal to 1."
        }

        if ($Count -and $Count -lt 1) {
          throw "invalid value for 'Count', must be greater than or equal to 1."
        }


        $PSO = [PSCustomObject]@{
            "triggerType" = ${TriggerType}
            "cron" = ${Cron}
            "beforeDeadLine" = ${BeforeDeadLine}
            "activeAfter" = ${ActiveAfter}
            "maxFirings" = ${MaxFirings}
            "count" = ${Count}
            "delay" = ${Delay}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Reminderescalationtrigger<PSCustomObject>

.DESCRIPTION

Convert from JSON to Reminderescalationtrigger<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Reminderescalationtrigger<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Reminderescalationtrigger
        $AllProperties = ("triggerType", "cron", "beforeDeadLine", "activeAfter", "maxFirings", "count", "delay")
        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 'triggerType' missing."
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "triggerType" = ${TriggerType}
            "cron" = ${Cron}
            "beforeDeadLine" = ${BeforeDeadLine}
            "activeAfter" = ${ActiveAfter}
            "maxFirings" = ${MaxFirings}
            "count" = ${Count}
            "delay" = ${Delay}
        }

        return $PSO
    }

}