Model/AdvancedSearch1ConditionRulesAttributesInner.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

AdvancedSearch1ConditionRulesAttributesInner<PSCustomObject>
#>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if ($match -eq 1) {
            return [PSCustomObject]@{
                "ActualType" = ${matchType}
                "ActualInstance" = ${matchInstance}
                "anyOfSchemas" = @("ProfileAttributeRuleDate1", "ProfileAttributeRuleId1", "ProfileAttributeRuleString1", "ProfileStatusRule1", "ProfileTypeRule1", "RiskRule1")
            }
        } else {
            throw "Error! The JSON payload doesn't matches any type defined in anyOf schemas ([ProfileAttributeRuleDate1, ProfileAttributeRuleId1, ProfileAttributeRuleString1, ProfileStatusRule1, ProfileTypeRule1, RiskRule1]). JSON Payload: $($Json)"
        }
    }
}