Model/CertificationTask.ps1

#
# Identity Security Cloud API - Next Generation Certification Campaigns
# 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

No description available.

.PARAMETER Id
The ID of the task
.PARAMETER TargetId
ID of the item for which the task is targeting
.PARAMETER Type
Type of the task
.PARAMETER TargetType
Type of the item being targeted by the task
.PARAMETER Status
Status of the task
.PARAMETER Errors
Generic localized reason for error
.PARAMETER ReassignmentTrails
Reassignment trails that lead to self certification during the reassignment
.OUTPUTS

CertificationTask<PSCustomObject>
#>


function Initialize-CertificationTask {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TargetId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("CREATE_CAMPAIGN", "SEARCH_CAMPAIGN", "GENERATE_CAMPAIGN", "ACTIVATE_CAMPAIGN", "COMPLETE_CAMPAIGN", "COMPLETE_CERTIFICATION", "REASSIGN_SUBJECTS_AND_ITEMS", "REASSIGN_CERTIFICATIONS", "FINISH_CAMPAIGN", "FINALIZE_ACTIVATE_CAMPAIGN", "DELETE_CAMPAIGN", "DELETE_CAMPAIGN_DATA", "FINISH_CERTIFICATION")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("CERTIFICATION", "CAMPAIGN")]
        [String]
        ${TargetType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("QUEUED", "IN_PROGRESS", "SUCCESS", "ERROR")]
        [String]
        ${Status},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${Errors},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${ReassignmentTrails}
    )

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

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "targetId" = ${TargetId}
            "type" = ${Type}
            "targetType" = ${TargetType}
            "status" = ${Status}
            "errors" = ${Errors}
            "reassignmentTrails" = ${ReassignmentTrails}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CertificationTask<PSCustomObject>

.DESCRIPTION

Convert from JSON to CertificationTask<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CertificationTask<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in CertificationTask
        $AllProperties = ("id", "targetId", "type", "targetType", "status", "errors", "reassignmentTrails", "created")
        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 "targetId"))) { #optional property not found
            $TargetId = $null
        } else {
            $TargetId = $JsonParameters.PSobject.Properties["targetId"].value
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "targetId" = ${TargetId}
            "type" = ${Type}
            "targetType" = ${TargetType}
            "status" = ${Status}
            "errors" = ${Errors}
            "reassignmentTrails" = ${ReassignmentTrails}
            "created" = ${Created}
        }

        return $PSO
    }

}