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

An entitlement to request for the machine account, with optional comment and access dates.

.PARAMETER Id
ID of the entitlement to request.
.PARAMETER Comment
Comment to include with the entitlement request.
.PARAMETER StartDate
Date and time when access to the entitlement starts. Must be in the future and, when `removeDate` is also set, before `removeDate`.
.PARAMETER RemoveDate
Date and time when access to the entitlement is removed. Must be in the future.
.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
    }

}