Model/Certification.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 CampaignRef
No description available.
.PARAMETER Phase
No description available.
.PARAMETER ReviewProgress
No description available.
.PARAMETER DueDate
The due date of the certification.
.PARAMETER DateSigned
The date the reviewer signed off on the certification. Omitted until the certification is signed off.
.PARAMETER DateFinished
The date the certification was finished.
.PARAMETER Reviewer
No description available.
.PARAMETER Reassignment
No description available.
.PARAMETER Completed
Indicates if all certification decisions have been made.
.PARAMETER DecisionsMade
The number of approve/revoke/acknowledge decisions that have been made by the reviewer.
.PARAMETER DecisionsTotal
The total number of approve/revoke/acknowledge decisions for the certification.
.PARAMETER CompletedSubjects
The number of subjects (identities, access profiles, roles, etc.) for which all decisions have been made and are complete.
.PARAMETER TotalSubjects
The total number of subjects (identities, access profiles, roles, etc.) in the certification, both complete and incomplete.
.PARAMETER Id
The certificationId
.PARAMETER Name
The name of the certification
.PARAMETER Created
The date the certification was created
.PARAMETER Modified
The date the certification was last modified
.PARAMETER ReauthRequired
Indicates whether any review items within this certification requires reauthentication before sign-off or completion
.OUTPUTS

Certification<PSCustomObject>
#>


function Initialize-Certification {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${CampaignRef},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("STAGED", "ACTIVE", "SIGNED")]
        [PSCustomObject]
        ${Phase},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("NOT_STARTED", "IN_PROGRESS", "DECISIONS_COMPLETE", "SIGNED")]
        [PSCustomObject]
        ${ReviewProgress},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.DateTime]
        ${DueDate},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${DateSigned},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${DateFinished},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Reviewer},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Reassignment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Boolean]
        ${Completed},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${DecisionsMade},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${DecisionsTotal},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${CompletedSubjects},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [Int32]
        ${TotalSubjects},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Created},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Modified},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${ReauthRequired} = $false
    )

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

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

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

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

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

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "campaignRef" = ${CampaignRef}
            "phase" = ${Phase}
            "reviewProgress" = ${ReviewProgress}
            "dueDate" = ${DueDate}
            "dateSigned" = ${DateSigned}
            "dateFinished" = ${DateFinished}
            "reviewer" = ${Reviewer}
            "reassignment" = ${Reassignment}
            "completed" = ${Completed}
            "decisionsMade" = ${DecisionsMade}
            "decisionsTotal" = ${DecisionsTotal}
            "completedSubjects" = ${CompletedSubjects}
            "totalSubjects" = ${TotalSubjects}
            "id" = ${Id}
            "name" = ${Name}
            "created" = ${Created}
            "modified" = ${Modified}
            "reauthRequired" = ${ReauthRequired}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Certification<PSCustomObject>

.DESCRIPTION

Convert from JSON to Certification<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Certification<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Certification
        $AllProperties = ("campaignRef", "phase", "reviewProgress", "dueDate", "dateSigned", "dateFinished", "reviewer", "reassignment", "completed", "decisionsMade", "decisionsTotal", "completedSubjects", "totalSubjects", "id", "name", "created", "modified", "reauthRequired")
        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 'campaignRef' missing."
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "campaignRef" = ${CampaignRef}
            "phase" = ${Phase}
            "reviewProgress" = ${ReviewProgress}
            "dueDate" = ${DueDate}
            "dateSigned" = ${DateSigned}
            "dateFinished" = ${DateFinished}
            "reviewer" = ${Reviewer}
            "reassignment" = ${Reassignment}
            "completed" = ${Completed}
            "decisionsMade" = ${DecisionsMade}
            "decisionsTotal" = ${DecisionsTotal}
            "completedSubjects" = ${CompletedSubjects}
            "totalSubjects" = ${TotalSubjects}
            "id" = ${Id}
            "name" = ${Name}
            "created" = ${Created}
            "modified" = ${Modified}
            "reauthRequired" = ${ReauthRequired}
        }

        return $PSO
    }

}