Model/Delegation.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 Id
The id of the delegation
.PARAMETER DelegatorId
The id of the delegator user
.PARAMETER DelegateId
The id of the delegate user
.PARAMETER Expiration
The expiration date of the delegation
.PARAMETER Expired
Indicates if the delegation is expired
.OUTPUTS

Delegation<PSCustomObject>
#>


function Initialize-NERMDelegation {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${DelegatorId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${DelegateId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Expiration},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${Expired}
    )

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "delegator_id" = ${DelegatorId}
            "delegate_id" = ${DelegateId}
            "expiration" = ${Expiration}
            "expired" = ${Expired}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Delegation<PSCustomObject>

.DESCRIPTION

Convert from JSON to Delegation<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Delegation<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMDelegation
        $AllProperties = ("id", "delegator_id", "delegate_id", "expiration", "expired", "created_at", "updated_at")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "delegator_id" = ${DelegatorId}
            "delegate_id" = ${DelegateId}
            "expiration" = ${Expiration}
            "expired" = ${Expired}
            "created_at" = ${CreatedAt}
            "updated_at" = ${UpdatedAt}
        }

        return $PSO
    }

}