nerm/src/PSSailpoint.NERM/Model/AskSecurityQuestionAction.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 NumberOfQuestions
The number of questions the user should answer upon login.
.PARAMETER TokenExpiration
The token expiration time, coordinates with token_expiration_type.
.PARAMETER TokenExpirationType
The token expiration type, coordinates with token_expiration.
.PARAMETER Archived
If the workflow action is archived or not.
.OUTPUTS

AskSecurityQuestionAction<PSCustomObject>
#>


function Initialize-NERMAskSecurityQuestionAction {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${WorkflowId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${NumberOfQuestions},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${TokenExpiration},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("hours", "days", "login attempts", "always")]
        [String]
        ${TokenExpirationType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${Archived} = $false
    )

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

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "description" = ${Description}
            "number_of_questions" = ${NumberOfQuestions}
            "token_expiration" = ${TokenExpiration}
            "token_expiration_type" = ${TokenExpirationType}
            "archived" = ${Archived}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to AskSecurityQuestionAction<PSCustomObject>

.DESCRIPTION

Convert from JSON to AskSecurityQuestionAction<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AskSecurityQuestionAction<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMAskSecurityQuestionAction
        $AllProperties = ("workflow_id", "description", "number_of_questions", "token_expiration", "token_expiration_type", "archived")
        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 "description"))) {
            throw "Error! JSON cannot be serialized due to the required property 'description' missing."
        } else {
            $Description = $JsonParameters.PSobject.Properties["description"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "workflow_id" = ${WorkflowId}
            "description" = ${Description}
            "number_of_questions" = ${NumberOfQuestions}
            "token_expiration" = ${TokenExpiration}
            "token_expiration_type" = ${TokenExpirationType}
            "archived" = ${Archived}
        }

        return $PSO
    }

}