Model/PublicIdentitiesCompositeEntry.ps1

#
# Identity Security Cloud API - Public Identities
# 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

A querySet entry that is either a TEXT clause or a nested COMPOSITE querySet.

.PARAMETER Json

JSON object

.OUTPUTS

PublicIdentitiesCompositeEntry<PSCustomObject>
#>

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

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

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

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

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

            foreach($property in $matchInstance.PsObject.Properties) {
                if ($null -ne $property.Value) {
                    $matchType = "PublicIdentitiesTextEntry"
                    $match++
                    break
                }
            }
        } catch {
            # fail to match the schema defined in oneOf, proceed to the next one
            Write-Debug "Failed to match 'PublicIdentitiesTextEntry' defined in oneOf (PublicIdentitiesCompositeEntry). 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 ([PublicIdentitiesNestedCompositeEntry, PublicIdentitiesTextEntry]). JSON Payload: $($Json)"
        } elseif ($match -eq 1) {
            return [PSCustomObject]@{
                "ActualType" = ${matchType}
                "ActualInstance" = ${matchInstance}
                "OneOfSchemas" = @("PublicIdentitiesNestedCompositeEntry", "PublicIdentitiesTextEntry")
            }
        } else {
            throw "Error! The JSON payload doesn't matches any type defined in oneOf schemas ([PublicIdentitiesNestedCompositeEntry, PublicIdentitiesTextEntry]). JSON Payload: $($Json)"
        }
    }
}