Model/Machineaccountcreaterequestinput.ps1

#
# Identity Security Cloud API - Machine Account Creation Request
# Use these APIs to interact with the Identity Security Cloud 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

Contains the required information for processing a user-initiated machine account creation request.

.PARAMETER SubtypeId
Subtype ID for which machine account create is enabled and user have the entitlement to create the machine account.
.PARAMETER FormId
Form ID selected by user for the machine account create request.
.PARAMETER OwnerIdentityId
Owner Identity ID. This identity will be assigned as an owner of the created machine account.
.PARAMETER MachineIdentityId
Machine identity to correlate with the created machine account. If not provided, a new machine identity will be created.
.PARAMETER Environment
Environment type to use for the machine account.
.PARAMETER Description
Description for the machine account.
.PARAMETER UserInput
Fields of the form linked to the subtype in approval settings.
.PARAMETER EntitlementIds
List of entitlement IDs to provision for created machine account.
.OUTPUTS

Machineaccountcreaterequestinput<PSCustomObject>
#>


function Initialize-Machineaccountcreaterequestinput {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SubtypeId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${FormId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OwnerIdentityId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${MachineIdentityId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Environment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${UserInput},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${EntitlementIds}
    )

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

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

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


        $PSO = [PSCustomObject]@{
            "subtypeId" = ${SubtypeId}
            "formId" = ${FormId}
            "ownerIdentityId" = ${OwnerIdentityId}
            "machineIdentityId" = ${MachineIdentityId}
            "environment" = ${Environment}
            "description" = ${Description}
            "userInput" = ${UserInput}
            "entitlementIds" = ${EntitlementIds}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Machineaccountcreaterequestinput<PSCustomObject>

.DESCRIPTION

Convert from JSON to Machineaccountcreaterequestinput<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Machineaccountcreaterequestinput<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Machineaccountcreaterequestinput
        $AllProperties = ("subtypeId", "formId", "ownerIdentityId", "machineIdentityId", "environment", "description", "userInput", "entitlementIds")
        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 'subtypeId' missing."
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "subtypeId" = ${SubtypeId}
            "formId" = ${FormId}
            "ownerIdentityId" = ${OwnerIdentityId}
            "machineIdentityId" = ${MachineIdentityId}
            "environment" = ${Environment}
            "description" = ${Description}
            "userInput" = ${UserInput}
            "entitlementIds" = ${EntitlementIds}
        }

        return $PSO
    }

}