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

#
# SailPoint Identity Security API - Machine Identity Lifecycle Actions
# Use these APIs to submit, list, retrieve, and cancel machine identity lifecycle actions (currently activate and deactivate for Agent machine identities only). 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 RequestId
Unique identifier for the created lifecycle request.
.PARAMETER Status
No description available.
.PARAMETER Action
No description available.
.PARAMETER TargetId
ID of the machine identity the request applies to.
.PARAMETER ResourceId
ID of the machine identity in its source system, when available.
.PARAMETER CreatedAt
Time when the lifecycle request was created (ISO-8601).
.OUTPUTS

LifecycleActionSubmitResponse<PSCustomObject>
#>


function Initialize-LifecycleActionSubmitResponse {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequestId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("RECEIVED", "PENDING_APPROVAL", "APPROVED", "REJECTED", "PROVISIONING", "COMPLETED", "FAILED", "CANCELING", "CANCELED")]
        [PSCustomObject]
        ${Status},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("DEACTIVATE", "ACTIVATE")]
        [PSCustomObject]
        ${Action},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TargetId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ResourceId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.DateTime]
        ${CreatedAt}
    )

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

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "requestId" = ${RequestId}
            "status" = ${Status}
            "action" = ${Action}
            "targetId" = ${TargetId}
            "resourceId" = ${ResourceId}
            "createdAt" = ${CreatedAt}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to LifecycleActionSubmitResponse<PSCustomObject>

.DESCRIPTION

Convert from JSON to LifecycleActionSubmitResponse<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

LifecycleActionSubmitResponse<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in LifecycleActionSubmitResponse
        $AllProperties = ("requestId", "status", "action", "targetId", "resourceId", "createdAt")
        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 'requestId' missing."
        }

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

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

        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 "targetId"))) {
            throw "Error! JSON cannot be serialized due to the required property 'targetId' missing."
        } else {
            $TargetId = $JsonParameters.PSobject.Properties["targetId"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "requestId" = ${RequestId}
            "status" = ${Status}
            "action" = ${Action}
            "targetId" = ${TargetId}
            "resourceId" = ${ResourceId}
            "createdAt" = ${CreatedAt}
        }

        return $PSO
    }

}