Model/ErrorModel.ps1

#
# Fly SDK API
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# Version: 1.0
# Contact: support@avepoint.com
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS
 
No summary available.
 
.DESCRIPTION
 
No description available.
 
.PARAMETER StatusCode
* `Continue` = 100 * `SwitchingProtocols` = 101 * `Processing` = 102 * `EarlyHints` = 103 * `OK` = 200 * `Created` = 201 * `Accepted` = 202 * `NonAuthoritativeInformation` = 203 * `NoContent` = 204 * `ResetContent` = 205 * `PartialContent` = 206 * `MultiStatus` = 207 * `AlreadyReported` = 208 * `IMUsed` = 226 * `Ambiguous` = 300 * `Ambiguous` = 300 * `Moved` = 301 * `Moved` = 301 * `Redirect` = 302 * `Redirect` = 302 * `RedirectMethod` = 303 * `RedirectMethod` = 303 * `NotModified` = 304 * `UseProxy` = 305 * `Unused` = 306 * `TemporaryRedirect` = 307 * `TemporaryRedirect` = 307 * `PermanentRedirect` = 308 * `BadRequest` = 400 * `Unauthorized` = 401 * `PaymentRequired` = 402 * `Forbidden` = 403 * `NotFound` = 404 * `MethodNotAllowed` = 405 * `NotAcceptable` = 406 * `ProxyAuthenticationRequired` = 407 * `RequestTimeout` = 408 * `Conflict` = 409 * `Gone` = 410 * `LengthRequired` = 411 * `PreconditionFailed` = 412 * `RequestEntityTooLarge` = 413 * `RequestUriTooLong` = 414 * `UnsupportedMediaType` = 415 * `RequestedRangeNotSatisfiable` = 416 * `ExpectationFailed` = 417 * `MisdirectedRequest` = 421 * `UnprocessableEntity` = 422 * `Locked` = 423 * `FailedDependency` = 424 * `UpgradeRequired` = 426 * `PreconditionRequired` = 428 * `TooManyRequests` = 429 * `RequestHeaderFieldsTooLarge` = 431 * `UnavailableForLegalReasons` = 451 * `InternalServerError` = 500 * `NotImplemented` = 501 * `BadGateway` = 502 * `ServiceUnavailable` = 503 * `GatewayTimeout` = 504 * `HttpVersionNotSupported` = 505 * `VariantAlsoNegotiates` = 506 * `InsufficientStorage` = 507 * `LoopDetected` = 508 * `NotExtended` = 510 * `NetworkAuthenticationRequired` = 511
.PARAMETER ErrorCode
The error code of current exception
.PARAMETER ErrorMessage
The error message of current exception
.PARAMETER RequestId
the request id of response
.PARAMETER Timestamp
The timestamp of current response
.OUTPUTS
 
ErrorModel<PSCustomObject>
#>


function Initialize-FlyErrorModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${StatusCode},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ErrorCode},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ErrorMessage},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequestId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Timestamp}
    )

    Process {
        'Creating PSCustomObject: Fly.Client => FlyErrorModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug


        $PSO = [PSCustomObject]@{
            "statusCode" = ${StatusCode}
            "errorCode" = ${ErrorCode}
            "errorMessage" = ${ErrorMessage}
            "requestId" = ${RequestId}
            "timestamp" = ${Timestamp}
        }

        return $PSO
    }
}

<#
.SYNOPSIS
 
Convert from JSON to ErrorModel<PSCustomObject>
 
.DESCRIPTION
 
Convert from JSON to ErrorModel<PSCustomObject>
 
.PARAMETER Json
 
Json object
 
.OUTPUTS
 
ErrorModel<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: Fly.Client => FlyErrorModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in FlyErrorModel
        $AllProperties = ("statusCode", "errorCode", "errorMessage", "requestId", "timestamp")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "statusCode"))) { #optional property not found
            $StatusCode = $null
        } else {
            $StatusCode = $JsonParameters.PSobject.Properties["statusCode"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "errorCode"))) { #optional property not found
            $ErrorCode = $null
        } else {
            $ErrorCode = $JsonParameters.PSobject.Properties["errorCode"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "errorMessage"))) { #optional property not found
            $ErrorMessage = $null
        } else {
            $ErrorMessage = $JsonParameters.PSobject.Properties["errorMessage"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "requestId"))) { #optional property not found
            $RequestId = $null
        } else {
            $RequestId = $JsonParameters.PSobject.Properties["requestId"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "timestamp"))) { #optional property not found
            $Timestamp = $null
        } else {
            $Timestamp = $JsonParameters.PSobject.Properties["timestamp"].value
        }

        $PSO = [PSCustomObject]@{
            "statusCode" = ${StatusCode}
            "errorCode" = ${ErrorCode}
            "errorMessage" = ${ErrorMessage}
            "requestId" = ${RequestId}
            "timestamp" = ${Timestamp}
        }

        return $PSO
    }

}