nerm/src/PSSailpoint.NERM/Model/WorkflowAction.ps1

#
# NERM API
# The NERM API accesss and modifies resources in your environment.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER WorkflowId
The workflow the workflow action belongs to.
.PARAMETER Description
The description of the workflow action.
.PARAMETER PageId
The page the workflow action should render.
.PARAMETER AddRequesterAsOwner
If the requester should be added as the owner of the profile to be created.
.PARAMETER EmailAttributeId
The attribute storing the email address for the workflow action.
.PARAMETER EmailAddresses
The email addresses for the workflow action.
.PARAMETER NewStatus
The new status for the Status Change workflow action.
.PARAMETER Archived
If the workflow action is archived or not.
.PARAMETER Skippable
If the workflow action is skippable or not.
.PARAMETER RequiresComment
If the workflow action requires a comment or not.
.OUTPUTS

WorkflowAction<PSCustomObject>
#>


function Initialize-NERMWorkflowAction {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${WorkflowId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PageId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${AddRequesterAsOwner} = $true,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${EmailAttributeId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${EmailAddresses},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${NewStatus},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${Archived} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${Skippable} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${RequiresComment} = $false
    )

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

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

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


        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "description" = ${Description}
            "page_id" = ${PageId}
            "add_requester_as_owner" = ${AddRequesterAsOwner}
            "email_attribute_id" = ${EmailAttributeId}
            "email_addresses" = ${EmailAddresses}
            "new_status" = ${NewStatus}
            "archived" = ${Archived}
            "skippable" = ${Skippable}
            "requires_comment" = ${RequiresComment}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to WorkflowAction<PSCustomObject>

.DESCRIPTION

Convert from JSON to WorkflowAction<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

WorkflowAction<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMWorkflowAction
        $AllProperties = ("workflow_id", "description", "page_id", "add_requester_as_owner", "email_attribute_id", "email_addresses", "new_status", "archived", "skippable", "requires_comment")
        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 'workflow_id' missing."
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "description" = ${Description}
            "page_id" = ${PageId}
            "add_requester_as_owner" = ${AddRequesterAsOwner}
            "email_attribute_id" = ${EmailAttributeId}
            "email_addresses" = ${EmailAddresses}
            "new_status" = ${NewStatus}
            "archived" = ${Archived}
            "skippable" = ${Skippable}
            "requires_comment" = ${RequiresComment}
        }

        return $PSO
    }

}