machine-identities-lifecycle-actions/src/PSSailpoint.MachineIdentitiesLifecycleActions/Model/LifecycleActionSubmitResponse.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 RequestId
Unique identifier for the created lifecycle request.
.PARAMETER Status
Initial lifecycle request status.
.PARAMETER Action
No description available.
.PARAMETER TargetId
Internal machine identity UUID for the lifecycle target.
.PARAMETER ResourceId
Connector resource id for the lifecycle target, when present.
.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)]
        [String]
        ${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
    }

}