beta/src/PSSailpointBeta/Model/Trigger.ps1

#
# IdentityNow Beta API
# Use these APIs to interact with the IdentityNow platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. 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: 3.1.0-beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Id
Unique identifier of the trigger.
.PARAMETER Name
Trigger Name.
.PARAMETER Type
No description available.
.PARAMETER Description
Trigger Description.
.PARAMETER InputSchema
The JSON schema of the payload that will be sent by the trigger to the subscribed service.
.PARAMETER ExampleInput
No description available.
.PARAMETER OutputSchema
The JSON schema of the response that will be sent by the subscribed service to the trigger in response to an event. This only applies to a trigger type of `REQUEST_RESPONSE`.
.PARAMETER ExampleOutput
No description available.
.OUTPUTS

Trigger<PSCustomObject>
#>


function Initialize-BetaTrigger {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("REQUEST_RESPONSE", "FIRE_AND_FORGET")]
        [PSCustomObject]
        ${Type},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${InputSchema},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ExampleInput},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OutputSchema},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ExampleOutput}
    )

    Process {
        'Creating PSCustomObject: PSSailpointBeta => BetaTrigger' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if ($null -eq $Id) {
            throw "invalid value for 'Id', 'Id' cannot be null."
        }

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

        if ($null -eq $Type) {
            throw "invalid value for 'Type', 'Type' cannot be null."
        }

        if ($null -eq $InputSchema) {
            throw "invalid value for 'InputSchema', 'InputSchema' cannot be null."
        }

        if ($null -eq $ExampleInput) {
            throw "invalid value for 'ExampleInput', 'ExampleInput' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "name" = ${Name}
            "type" = ${Type}
            "description" = ${Description}
            "inputSchema" = ${InputSchema}
            "exampleInput" = ${ExampleInput}
            "outputSchema" = ${OutputSchema}
            "exampleOutput" = ${ExampleOutput}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Trigger<PSCustomObject>

.DESCRIPTION

Convert from JSON to Trigger<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Trigger<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: PSSailpointBeta => BetaTrigger' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in BetaTrigger
        $AllProperties = ("id", "name", "type", "description", "inputSchema", "exampleInput", "outputSchema", "exampleOutput")
        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 "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 "type"))) {
            throw "Error! JSON cannot be serialized due to the required property 'type' missing."
        } else {
            $Type = $JsonParameters.PSobject.Properties["type"].value
        }

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "exampleInput"))) {
            throw "Error! JSON cannot be serialized due to the required property 'exampleInput' missing."
        } else {
            $ExampleInput = $JsonParameters.PSobject.Properties["exampleInput"].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 "outputSchema"))) { #optional property not found
            $OutputSchema = $null
        } else {
            $OutputSchema = $JsonParameters.PSobject.Properties["outputSchema"].value
        }

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "name" = ${Name}
            "type" = ${Type}
            "description" = ${Description}
            "inputSchema" = ${InputSchema}
            "exampleInput" = ${ExampleInput}
            "outputSchema" = ${OutputSchema}
            "exampleOutput" = ${ExampleOutput}
        }

        return $PSO
    }

}