Model/JsonPatchOperationValue.ps1

#
# Identity Security Cloud Beta API
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. 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: 3.1.0-beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

The value to be used for the operation, required for ""add"" and ""replace"" operations

.PARAMETER Json

JSON object

.OUTPUTS

JsonPatchOperationValue<PSCustomObject>
#>

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

    Process {
        $match = 0
        $matchType = $null
        $matchInstance = $null

        # try to match ArrayInner[] defined in the oneOf schemas
        try {
            $matchInstance = ConvertFrom-BetaJsonToArrayInner[] $Json

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "ArrayInner[]"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'ArrayInner[]' defined in oneOf (BetaJsonPatchOperationValue). Proceeding to the next one if any."
        }

        # try to match Boolean defined in the oneOf schemas
        try {
            $matchInstance = ConvertFrom-BetaJsonToBoolean $Json

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "Boolean"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'Boolean' defined in oneOf (BetaJsonPatchOperationValue). Proceeding to the next one if any."
        }

        # try to match Int32 defined in the oneOf schemas
        try {
            $matchInstance = ConvertFrom-BetaJsonToInt32 $Json

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "Int32"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'Int32' defined in oneOf (BetaJsonPatchOperationValue). Proceeding to the next one if any."
        }

        # try to match String defined in the oneOf schemas
        try {
            $matchInstance = ConvertFrom-BetaJsonToString $Json

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "String"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'String' defined in oneOf (BetaJsonPatchOperationValue). Proceeding to the next one if any."
        }

        # try to match SystemCollectionsHashtable defined in the oneOf schemas
        try {
            $matchInstance = ConvertFrom-BetaJsonToSystemCollectionsHashtable $Json

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "SystemCollectionsHashtable"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'SystemCollectionsHashtable' defined in oneOf (BetaJsonPatchOperationValue). Proceeding to the next one if any."
        }

        if ($match -gt 1) {
            throw "Error! The JSON payload matches more than one type defined in oneOf schemas ([ArrayInner[], Boolean, Int32, String, SystemCollectionsHashtable]). JSON Payload: $($Json)"
        } elseif ($match -eq 1) {
            return [PSCustomObject]@{
                "ActualType" = ${matchType}
                "ActualInstance" = ${matchInstance}
                "OneOfSchemas" = @("ArrayInner[]", "Boolean", "Int32", "String", "SystemCollectionsHashtable")
            }
        } else {
            throw "Error! The JSON payload doesn't matches any type defined in oneOf schemas ([ArrayInner[], Boolean, Int32, String, SystemCollectionsHashtable]). JSON Payload: $($Json)"
        }
    }
}