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

SubmitUsers200Response<PSCustomObject>
#>

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

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

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

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

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

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