Model/PageElement1.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 Uid
The user-specified identifier for the record
.PARAMETER ElementType
The type of content on the page.
.PARAMETER PageUid
The user-specified identifier of the page record this applies to; one of page_id or page_uid must be present.
.PARAMETER PageId
The id of the page record this applies to; one of page_id or page_uid must be present.
.PARAMETER ElementUid
The user-specified identifier of the record (Form or PageContent) this applies to; one of element_id or element_uid must be present.
.PARAMETER ElementId
The id of the record (Form or PageContent) this applies to; one of element_id or element_uid must be present.
.PARAMETER Order
The ordinal position of the attribute in the user-interface page.
.OUTPUTS

PageElement1<PSCustomObject>
#>


function Initialize-NERMPageElement1 {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Uid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("PageContent", "Form")]
        [String]
        ${ElementType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PageUid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PageId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ElementUid},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ElementId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${Order}
    )

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

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


        $PSO = [PSCustomObject]@{
            "uid" = ${Uid}
            "element_type" = ${ElementType}
            "page_uid" = ${PageUid}
            "page_id" = ${PageId}
            "element_uid" = ${ElementUid}
            "element_id" = ${ElementId}
            "order" = ${Order}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to PageElement1<PSCustomObject>

.DESCRIPTION

Convert from JSON to PageElement1<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

PageElement1<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMPageElement1
        $AllProperties = ("id", "uid", "element_type", "page_uid", "page_id", "element_uid", "element_id", "order")
        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 'element_type' missing."
        }

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

        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 "uid"))) { #optional property not found
            $Uid = $null
        } else {
            $Uid = $JsonParameters.PSobject.Properties["uid"].value
        }

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "uid" = ${Uid}
            "element_type" = ${ElementType}
            "page_uid" = ${PageUid}
            "page_id" = ${PageId}
            "element_uid" = ${ElementUid}
            "element_id" = ${ElementId}
            "order" = ${Order}
        }

        return $PSO
    }

}