nerm/src/PSSailpoint.NERM/Model/AdvancedSearchConditionRulesAttributesInner.ps1

#
# NERM API
# The NERM API accesss and modifies resources in your environment.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Json

JSON object

.OUTPUTS

AdvancedSearchConditionRulesAttributesInner<PSCustomObject>
#>

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

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

        if ($match -ne 0) { # no match yet
            # try to match ProfileAttributeRuleDate defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToProfileAttributeRuleDate $Json

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

        if ($match -ne 0) { # no match yet
            # try to match ProfileAttributeRuleId defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToProfileAttributeRuleId $Json

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

        if ($match -ne 0) { # no match yet
            # try to match ProfileAttributeRuleString defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToProfileAttributeRuleString $Json

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

        if ($match -ne 0) { # no match yet
            # try to match ProfileStatusRule defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToProfileStatusRule $Json

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

        if ($match -ne 0) { # no match yet
            # try to match ProfileTypeRule defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToProfileTypeRule $Json

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

        if ($match -ne 0) { # no match yet
            # try to match RiskRule defined in the anyOf schemas
            try {
                $matchInstance = ConvertFrom-NERMJsonToRiskRule $Json

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

        if ($match -eq 1) {
            return [PSCustomObject]@{
                "ActualType" = ${matchType}
                "ActualInstance" = ${matchInstance}
                "anyOfSchemas" = @("ProfileAttributeRuleDate", "ProfileAttributeRuleId", "ProfileAttributeRuleString", "ProfileStatusRule", "ProfileTypeRule", "RiskRule")
            }
        } else {
            throw "Error! The JSON payload doesn't matches any type defined in anyOf schemas ([ProfileAttributeRuleDate, ProfileAttributeRuleId, ProfileAttributeRuleString, ProfileStatusRule, ProfileTypeRule, RiskRule]). JSON Payload: $($Json)"
        }
    }
}