Model/CampaignSearchBasedParams.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

Must be set only if the campaign is created using SEARCH.

.PARAMETER SearchType
If the campaign type is `Identity`, then the searchType must be set.
.PARAMETER Query
The scope for the campaign. If the searchType is `Identity`, then one of `query` or `identityIds` must be set.
.PARAMETER IdentityIds
A direct list of identities to include in this campaign. If the searchType is `Identity`, then one of `query` or `identityIds` must be set.
.PARAMETER AccessConstraints
Further reduces the scope of the campaign by excluding identities (from `query` or `identityIds`) that do not have this access.
.OUTPUTS

CampaignSearchBasedParams<PSCustomObject>
#>


function Initialize-CampaignSearchBasedParams {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("IDENTITY", "ACCESS")]
        [String]
        ${SearchType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Query},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${IdentityIds},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${AccessConstraints}
    )

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


        $PSO = [PSCustomObject]@{
            "searchType" = ${SearchType}
            "query" = ${Query}
            "identityIds" = ${IdentityIds}
            "accessConstraints" = ${AccessConstraints}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CampaignSearchBasedParams<PSCustomObject>

.DESCRIPTION

Convert from JSON to CampaignSearchBasedParams<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CampaignSearchBasedParams<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in CampaignSearchBasedParams
        $AllProperties = ("searchType", "query", "identityIds", "accessConstraints")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "searchType" = ${SearchType}
            "query" = ${Query}
            "identityIds" = ${IdentityIds}
            "accessConstraints" = ${AccessConstraints}
        }

        return $PSO
    }

}