nerm/src/PSSailpoint.NERM/Model/User1.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 Name
The user name
.PARAMETER Email
The user email
.PARAMETER Type
The user type
.PARAMETER ProfileId
The user profile id. Not required for NeprofileUser
.PARAMETER Title
The user description
.PARAMETER Status
The user status
.PARAMETER Login
The user login
.PARAMETER GroupStrings
The user group strings
.PARAMETER Locale
The locale the user prefers to use
.PARAMETER Password
The user password. Not required for NeprofileUser
.PARAMETER SailpointIdentityId
The SailPoint Identity ID associated with this user
.OUTPUTS

User1<PSCustomObject>
#>


function Initialize-NERMUser1 {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Email},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("NeprofileUser", "NeaccessUser")]
        [String]
        ${Type} = "NeprofileUser",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ProfileId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Title},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("Active", "Pending", "Disabled")]
        [String]
        ${Status},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Login},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${GroupStrings},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Locale},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Password},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SailpointIdentityId}
    )

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "name" = ${Name}
            "email" = ${Email}
            "type" = ${Type}
            "profile_id" = ${ProfileId}
            "title" = ${Title}
            "status" = ${Status}
            "login" = ${Login}
            "group_strings" = ${GroupStrings}
            "locale" = ${Locale}
            "password" = ${Password}
            "sailpoint_identity_id" = ${SailpointIdentityId}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to User1<PSCustomObject>

.DESCRIPTION

Convert from JSON to User1<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

User1<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMUser1
        $AllProperties = ("name", "email", "type", "profile_id", "title", "status", "login", "group_strings", "locale", "password", "sailpoint_identity_id")
        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 'name' missing."
        }

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "name" = ${Name}
            "email" = ${Email}
            "type" = ${Type}
            "profile_id" = ${ProfileId}
            "title" = ${Title}
            "status" = ${Status}
            "login" = ${Login}
            "group_strings" = ${GroupStrings}
            "locale" = ${Locale}
            "password" = ${Password}
            "sailpoint_identity_id" = ${SailpointIdentityId}
        }

        return $PSO
    }

}