Model/WorkflowTriggerAttributes.ps1

#
# Identity Security Cloud V2024 API
# 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: v2024
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

Workflow Trigger Attributes.

.PARAMETER Json

JSON object

.OUTPUTS

WorkflowTriggerAttributes<PSCustomObject>
#>

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

    Process {
        $match = 0
        $matchType = $null
        $matchInstance = $null

        # nullable check
        if ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") {
            return [PSCustomObject]@{
                "ActualType" = $null
                "ActualInstance" = $null
                "AnyOfSchemas" = @("EventAttributes", "ExternalAttributes", "ScheduledAttributes")
            }
        }

        if ($match -ne 0) { # no match yet
            # try to match EventAttributes defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-V2024JsonToEventAttributes $Json

                foreach($property in $matchInstance.PsObject.Properties) {
                    if ($null -ne $property.Value) {
                        $matchType = "EventAttributes"
                        $match++
                        break
                    }
                }
            } catch {
                # fail to match the schema defined in anyOf, proceed to the next one
                Write-Debug "Failed to match 'EventAttributes' defined in anyOf (V2024WorkflowTriggerAttributes). Proceeding to the next one if any."
            }
        }

        if ($match -ne 0) { # no match yet
            # try to match ExternalAttributes defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-V2024JsonToExternalAttributes $Json

                foreach($property in $matchInstance.PsObject.Properties) {
                    if ($null -ne $property.Value) {
                        $matchType = "ExternalAttributes"
                        $match++
                        break
                    }
                }
            } catch {
                # fail to match the schema defined in anyOf, proceed to the next one
                Write-Debug "Failed to match 'ExternalAttributes' defined in anyOf (V2024WorkflowTriggerAttributes). Proceeding to the next one if any."
            }
        }

        if ($match -ne 0) { # no match yet
            # try to match ScheduledAttributes defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-V2024JsonToScheduledAttributes $Json

                foreach($property in $matchInstance.PsObject.Properties) {
                    if ($null -ne $property.Value) {
                        $matchType = "ScheduledAttributes"
                        $match++
                        break
                    }
                }
            } catch {
                # fail to match the schema defined in anyOf, proceed to the next one
                Write-Debug "Failed to match 'ScheduledAttributes' defined in anyOf (V2024WorkflowTriggerAttributes). Proceeding to the next one if any."
            }
        }

        if ($match -eq 1) {
            return [PSCustomObject]@{
                "ActualType" = ${matchType}
                "ActualInstance" = ${matchInstance}
                "anyOfSchemas" = @("EventAttributes", "ExternalAttributes", "ScheduledAttributes")
            }
        } else {
            throw "Error! The JSON payload doesn't matches any type defined in anyOf schemas ([EventAttributes, ExternalAttributes, ScheduledAttributes]). JSON Payload: $($Json)"
        }
    }
}