Model/DeviceInfoExtended.ps1

#
# Torizon OTA
# No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
# Version: 2.0-Beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER DeviceName
No description available.
.PARAMETER DeviceId
No description available.
.PARAMETER LastSeen
No description available.
.PARAMETER CreatedAt
No description available.
.PARAMETER ActivatedAt
No description available.
.PARAMETER DeviceStatus
No description available.
.PARAMETER Notes
No description available.
.PARAMETER LastUpdated
No description available.
.PARAMETER DeviceFleets
No description available.
.PARAMETER DevicePackages
No description available.
.PARAMETER DeviceTags
No description available.
.PARAMETER NetworkInfo
No description available.
.OUTPUTS

DeviceInfoExtended<PSCustomObject>
#>


function Initialize-TorizonPlatformAPIDeviceInfoExtended {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DeviceName},
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DeviceId},
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${LastSeen},
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [System.DateTime]
        ${CreatedAt},
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ActivatedAt},
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("NotSeen", "UpdateAssigned", "UpdateAssignmentRejected", "UpdateInFlight", "UpdateCancelRequested", "UpdateCanceled", "UpdateCompleted", "UpToDate", "Outdated", "Error", "UpdatePending")]
        [PSCustomObject]
        ${DeviceStatus},
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Notes},
        [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${LastUpdated},
        [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${DeviceFleets},
        [Parameter(Position = 9, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${DevicePackages},
        [Parameter(Position = 10, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${DeviceTags},
        [Parameter(Position = 11, ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${NetworkInfo}
    )

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

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

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

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

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

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


        $PSO = [PSCustomObject]@{
            "deviceName" = ${DeviceName}
            "deviceId" = ${DeviceId}
            "lastSeen" = ${LastSeen}
            "createdAt" = ${CreatedAt}
            "activatedAt" = ${ActivatedAt}
            "deviceStatus" = ${DeviceStatus}
            "notes" = ${Notes}
            "lastUpdated" = ${LastUpdated}
            "deviceFleets" = ${DeviceFleets}
            "devicePackages" = ${DevicePackages}
            "deviceTags" = ${DeviceTags}
            "networkInfo" = ${NetworkInfo}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to DeviceInfoExtended<PSCustomObject>

.DESCRIPTION

Convert from JSON to DeviceInfoExtended<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

DeviceInfoExtended<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in TorizonPlatformAPIDeviceInfoExtended
        $AllProperties = ("deviceName", "deviceId", "lastSeen", "createdAt", "activatedAt", "deviceStatus", "notes", "lastUpdated", "deviceFleets", "devicePackages", "deviceTags", "networkInfo")
        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 'deviceName' missing."
        }

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

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "deviceName" = ${DeviceName}
            "deviceId" = ${DeviceId}
            "lastSeen" = ${LastSeen}
            "createdAt" = ${CreatedAt}
            "activatedAt" = ${ActivatedAt}
            "deviceStatus" = ${DeviceStatus}
            "notes" = ${Notes}
            "lastUpdated" = ${LastUpdated}
            "deviceFleets" = ${DeviceFleets}
            "devicePackages" = ${DevicePackages}
            "deviceTags" = ${DeviceTags}
            "networkInfo" = ${NetworkInfo}
        }

        return $PSO
    }

}