beta/src/PSSailpointBeta/Model/AccessItemAssociatedAccessItem.ps1

#
# IdentityNow Beta API
# Use these APIs to interact with the IdentityNow 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

No description available.

.PARAMETER Json

JSON object

.OUTPUTS

AccessItemAssociatedAccessItem<PSCustomObject>
#>

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

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

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

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

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

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

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

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

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

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

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

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