Model/AccountV2Recommendation.ps1

#
# SailPoint Identity Security API - Accounts
# Use these APIs to interact with the SailPoint Identity Security 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

Indicates that the account is currently classified as one type but is recommended to be a different one.

.PARAMETER Type
Recommended type of account.
.PARAMETER Method
Method used to produce the recommendation. DISCOVERY - suggested by AI, SOURCE - the account comes from a source flagged as containing machine accounts, CRITERIA - the account satisfies classification criteria.
.PARAMETER MachineLikelihood
Ranked likelihood that this account is a machine account. Present when machine-account recommendation enrichment is available for the tenant.
.PARAMETER Explanation
Reasons supporting the machine-account recommendation. Never null; an empty array when no explanation is available.
.OUTPUTS

AccountV2Recommendation<PSCustomObject>
#>


function Initialize-AccountV2Recommendation {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("HUMAN", "MACHINE")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("DISCOVERY", "SOURCE", "CRITERIA")]
        [String]
        ${Method},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MachineLikelihood},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${Explanation}
    )

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

        if ($MachineLikelihood -and $MachineLikelihood -gt 3) {
          throw "invalid value for 'MachineLikelihood', must be smaller than or equal to 3."
        }

        if ($MachineLikelihood -and $MachineLikelihood -lt 0) {
          throw "invalid value for 'MachineLikelihood', must be greater than or equal to 0."
        }


        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "method" = ${Method}
            "machineLikelihood" = ${MachineLikelihood}
            "explanation" = ${Explanation}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to AccountV2Recommendation<PSCustomObject>

.DESCRIPTION

Convert from JSON to AccountV2Recommendation<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

AccountV2Recommendation<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in AccountV2Recommendation
        $AllProperties = ("type", "method", "machineLikelihood", "explanation")
        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 "type"))) { #optional property not found
            $Type = $null
        } else {
            $Type = $JsonParameters.PSobject.Properties["type"].value
        }

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

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

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

        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "method" = ${Method}
            "machineLikelihood" = ${MachineLikelihood}
            "explanation" = ${Explanation}
        }

        return $PSO
    }

}