v3/src/PSSailpoint/Model/SearchDocument.ps1

#
# IdentityNow V3 API
# Use these APIs to interact with the IdentityNow 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: 3.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Json

JSON object

.OUTPUTS

SearchDocument<PSCustomObject>
#>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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