Model/CampaignReference.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 unique ID of the campaign.
.PARAMETER Name
The name of the campaign.
.PARAMETER Description
The description of the campaign set by the admin who created it.
.PARAMETER Type
No description available.
.PARAMETER MandatoryCommentRequirement
No description available.
.PARAMETER RecommendationsEnabled
Indicates if the campaign related recommendations enabled.
.PARAMETER Reviewer
No description available.
.PARAMETER GenerationType
No description available.
.OUTPUTS

CampaignReference<PSCustomObject>
#>


function Initialize-CampaignReference {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("IDENTITY", "UNCORRELATED_ACCOUNT", "MACHINE_ACCOUNT")]
        [PSCustomObject]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ALL_DECISIONS", "REVOKE_ONLY_DECISIONS", "NO_DECISIONS")]
        [PSCustomObject]
        ${MandatoryCommentRequirement},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${RecommendationsEnabled} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Reviewer},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("SEARCH", "CAMPAIGN_FILTER", "NO_FILTER")]
        [PSCustomObject]
        ${GenerationType}
    )

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

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

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "name" = ${Name}
            "description" = ${Description}
            "type" = ${Type}
            "mandatoryCommentRequirement" = ${MandatoryCommentRequirement}
            "recommendationsEnabled" = ${RecommendationsEnabled}
            "reviewer" = ${Reviewer}
            "generationType" = ${GenerationType}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CampaignReference<PSCustomObject>

.DESCRIPTION

Convert from JSON to CampaignReference<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CampaignReference<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in CampaignReference
        $AllProperties = ("id", "name", "description", "type", "mandatoryCommentRequirement", "recommendationsEnabled", "reviewer", "generationType")
        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 "name"))) {
            throw "Error! JSON cannot be serialized due to the required property 'name' missing."
        } else {
            $Name = $JsonParameters.PSobject.Properties["name"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "description"))) { #optional property not found
            $Description = $null
        } else {
            $Description = $JsonParameters.PSobject.Properties["description"].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 "mandatoryCommentRequirement"))) { #optional property not found
            $MandatoryCommentRequirement = $null
        } else {
            $MandatoryCommentRequirement = $JsonParameters.PSobject.Properties["mandatoryCommentRequirement"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "name" = ${Name}
            "description" = ${Description}
            "type" = ${Type}
            "mandatoryCommentRequirement" = ${MandatoryCommentRequirement}
            "recommendationsEnabled" = ${RecommendationsEnabled}
            "reviewer" = ${Reviewer}
            "generationType" = ${GenerationType}
        }

        return $PSO
    }

}