machine-account-creation-request/src/PSSailpoint.MachineAccountCreationRequest/Model/MachineAccountCreateEntitlement.ps1

#
# SailPoint Identity Security API - Machine Account Creation Request
# Use these APIs to interact with the SailPoint Identity Security platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
# Version: v1
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

One entitlement to provision on the created machine account. `id` is the entitlement id. Comment and access dates are optional.

.PARAMETER Id
Entitlement id to provision. Not required to be a UUID.
.PARAMETER Comment
Justification stored with the entitlement request.
.PARAMETER StartDate
When access starts. Must be in the future and before `removeDate` when both are set.
.PARAMETER RemoveDate
When access ends. Must be in the future and after `startDate` when both are set.
.OUTPUTS

MachineAccountCreateEntitlement<PSCustomObject>
#>


function Initialize-MachineAccountCreateEntitlement {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Comment} = "",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${StartDate},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${RemoveDate}
    )

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

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "comment" = ${Comment}
            "startDate" = ${StartDate}
            "removeDate" = ${RemoveDate}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to MachineAccountCreateEntitlement<PSCustomObject>

.DESCRIPTION

Convert from JSON to MachineAccountCreateEntitlement<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

MachineAccountCreateEntitlement<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in MachineAccountCreateEntitlement
        $AllProperties = ("id", "comment", "startDate", "removeDate")
        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 'id' missing."
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "comment" = ${Comment}
            "startDate" = ${StartDate}
            "removeDate" = ${RemoveDate}
        }

        return $PSO
    }

}