Model/ExternalPackage.ps1

#
# Torizon OTA
# This API is rate limited and will return the following headers for each API call. - X-RateLimit-Limit - The total number of requests allowed within a time period - X-RateLimit-Remaining - The total number of requests still allowed until the end of the rate limiting period - X-RateLimit-Reset - The number of seconds until the limit is fully reset In addition, if an API client is rate limited, it will receive a HTTP 420 response with the following header: - Retry-After - The number of seconds to wait until this request is allowed
# Version: 2.0-Beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER PkgType
No description available.
.PARAMETER Uri
No description available.
.PARAMETER CreatedAt
No description available.
.PARAMETER HardwareIds
No description available.
.PARAMETER DelegationOrigin
No description available.
.PARAMETER Name
No description available.
.PARAMETER Version
No description available.
.PARAMETER Size
No description available.
.PARAMETER Hashes
No description available.
.PARAMETER ProprietaryMeta
No description available.
.PARAMETER PackageId
No description available.
.OUTPUTS

ExternalPackage<PSCustomObject>
#>


function Initialize-TorizonPlatformAPIExternalPackage {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PkgType},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Uri},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${CreatedAt},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${HardwareIds},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DelegationOrigin},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Version},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [Int64]
        ${Size},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${Hashes},
        [Parameter(Position = 9, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ProprietaryMeta},
        [Parameter(Position = 10, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${PackageId}
    )

    Process {
        'Creating PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIExternalPackage' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if ($null -eq $DelegationOrigin) {
            throw "invalid value for 'DelegationOrigin', 'DelegationOrigin' cannot be null."
        }

        if ($null -eq $Name) {
            throw "invalid value for 'Name', 'Name' cannot be null."
        }

        if ($null -eq $Version) {
            throw "invalid value for 'Version', 'Version' cannot be null."
        }

        if ($null -eq $Size) {
            throw "invalid value for 'Size', 'Size' cannot be null."
        }

        if ($null -eq $Hashes) {
            throw "invalid value for 'Hashes', 'Hashes' cannot be null."
        }

        if ($null -eq $PackageId) {
            throw "invalid value for 'PackageId', 'PackageId' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "pkgType" = ${PkgType}
            "uri" = ${Uri}
            "createdAt" = ${CreatedAt}
            "hardwareIds" = ${HardwareIds}
            "delegationOrigin" = ${DelegationOrigin}
            "name" = ${Name}
            "version" = ${Version}
            "size" = ${Size}
            "hashes" = ${Hashes}
            "proprietaryMeta" = ${ProprietaryMeta}
            "packageId" = ${PackageId}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to ExternalPackage<PSCustomObject>

.DESCRIPTION

Convert from JSON to ExternalPackage<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ExternalPackage<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIExternalPackage' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in TorizonPlatformAPIExternalPackage
        $AllProperties = ("pkgType", "uri", "createdAt", "hardwareIds", "delegationOrigin", "name", "version", "size", "hashes", "proprietaryMeta", "packageId")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'delegationOrigin' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "delegationOrigin"))) {
            throw "Error! JSON cannot be serialized due to the required property 'delegationOrigin' missing."
        } else {
            $DelegationOrigin = $JsonParameters.PSobject.Properties["delegationOrigin"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) {
            throw "Error! JSON cannot be serialized due to the required property 'name' missing."
        } else {
            $Name = $JsonParameters.PSobject.Properties["name"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "version"))) {
            throw "Error! JSON cannot be serialized due to the required property 'version' missing."
        } else {
            $Version = $JsonParameters.PSobject.Properties["version"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "size"))) {
            throw "Error! JSON cannot be serialized due to the required property 'size' missing."
        } else {
            $Size = $JsonParameters.PSobject.Properties["size"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "hashes"))) {
            throw "Error! JSON cannot be serialized due to the required property 'hashes' missing."
        } else {
            $Hashes = $JsonParameters.PSobject.Properties["hashes"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "packageId"))) {
            throw "Error! JSON cannot be serialized due to the required property 'packageId' missing."
        } else {
            $PackageId = $JsonParameters.PSobject.Properties["packageId"].value
        }

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "pkgType" = ${PkgType}
            "uri" = ${Uri}
            "createdAt" = ${CreatedAt}
            "hardwareIds" = ${HardwareIds}
            "delegationOrigin" = ${DelegationOrigin}
            "name" = ${Name}
            "version" = ${Version}
            "size" = ${Size}
            "hashes" = ${Hashes}
            "proprietaryMeta" = ${ProprietaryMeta}
            "packageId" = ${PackageId}
        }

        return $PSO
    }

}