Model/WorkflowSession1.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 id.
.PARAMETER RequesterId
The requester's id.
.PARAMETER RequesterType
The requester type.
.PARAMETER ProfileId
The profile this workflow session will be working with. Only Applicable for Update workflows
.PARAMETER ProfileIds
The profiles this workflow session will be working with. Only Applicable for Batch workflows
.PARAMETER Attributes
The attributes associated with the workflow session.
.OUTPUTS

WorkflowSession1<PSCustomObject>
#>


function Initialize-NERMWorkflowSession1 {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${WorkflowId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequesterId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("User", "NeprofileUser", "NeaccessUser")]
        [String]
        ${RequesterType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ProfileId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${ProfileIds},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${Attributes}
    )

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

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

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

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


        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "requester_id" = ${RequesterId}
            "requester_type" = ${RequesterType}
            "profile_id" = ${ProfileId}
            "profile_ids" = ${ProfileIds}
            "attributes" = ${Attributes}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to WorkflowSession1<PSCustomObject>

.DESCRIPTION

Convert from JSON to WorkflowSession1<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

WorkflowSession1<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMWorkflowSession1
        $AllProperties = ("workflow_id", "requester_id", "requester_type", "profile_id", "profile_ids", "attributes")
        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 "requester_id"))) {
            throw "Error! JSON cannot be serialized due to the required property 'requester_id' missing."
        } else {
            $RequesterId = $JsonParameters.PSobject.Properties["requester_id"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "requester_id" = ${RequesterId}
            "requester_type" = ${RequesterType}
            "profile_id" = ${ProfileId}
            "profile_ids" = ${ProfileIds}
            "attributes" = ${Attributes}
        }

        return $PSO
    }

}