machine-identities-lifecycle-actions/src/PSSailpoint.MachineIdentitiesLifecycleActions/Model/LifecycleActionSubmitRequest.ps1

#
# Identity Security Cloud API - Machine Identity Lifecycle Actions
# Use these APIs to submit, list, retrieve, and cancel machine identity lifecycle actions (for example agent activate and deactivate). 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

No description available.

.PARAMETER Action
No description available.
.PARAMETER Comments
Optional submit-time comments. At most 10 comments are allowed per request; each comment must be non-empty and at most 1000 characters.
.OUTPUTS

LifecycleActionSubmitRequest<PSCustomObject>
#>


function Initialize-LifecycleActionSubmitRequest {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("DEACTIVATE", "ACTIVATE")]
        [PSCustomObject]
        ${Action},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Comments}
    )

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

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

        if (!$Comments -and $Comments.length -gt 10) {
            throw "invalid value for 'Comments', number of items must be less than or equal to 10."
        }


        $PSO = [PSCustomObject]@{
            "action" = ${Action}
            "comments" = ${Comments}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to LifecycleActionSubmitRequest<PSCustomObject>

.DESCRIPTION

Convert from JSON to LifecycleActionSubmitRequest<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

LifecycleActionSubmitRequest<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in LifecycleActionSubmitRequest
        $AllProperties = ("action", "comments")
        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 'action' missing."
        }

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

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

        $PSO = [PSCustomObject]@{
            "action" = ${Action}
            "comments" = ${Comments}
        }

        return $PSO
    }

}