Model/Package.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 Name No description available. .PARAMETER Version No description available. .PARAMETER PackageId No description available. .PARAMETER Size No description available. .PARAMETER Hashes No description available. .PARAMETER PkgType No description available. .PARAMETER HardwareIds No description available. .PARAMETER CreatedAt No description available. .PARAMETER Uri No description available. .PARAMETER ProprietaryMeta No description available. .PARAMETER Comment No description available. .OUTPUTS Package<PSCustomObject> #> function Initialize-TorizonPlatformAPIPackage { [CmdletBinding()] Param ( [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)] [String] ${Name}, [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] [String] ${Version}, [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] [String] ${PackageId}, [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)] [Int64] ${Size}, [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)] [System.Collections.Hashtable] ${Hashes}, [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)] [String] ${PkgType}, [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)] [String[]] ${HardwareIds}, [Parameter(Position = 7, ValueFromPipelineByPropertyName = $true)] [System.Nullable[System.DateTime]] ${CreatedAt}, [Parameter(Position = 8, ValueFromPipelineByPropertyName = $true)] [String] ${Uri}, [Parameter(Position = 9, ValueFromPipelineByPropertyName = $true)] [String] ${ProprietaryMeta}, [Parameter(Position = 10, ValueFromPipelineByPropertyName = $true)] [String] ${Comment} ) Process { 'Creating PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIPackage' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug 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 $PackageId) { throw "invalid value for 'PackageId', 'PackageId' 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." } $PSO = [PSCustomObject]@{ "name" = ${Name} "version" = ${Version} "packageId" = ${PackageId} "size" = ${Size} "hashes" = ${Hashes} "pkgType" = ${PkgType} "hardwareIds" = ${HardwareIds} "createdAt" = ${CreatedAt} "uri" = ${Uri} "proprietaryMeta" = ${ProprietaryMeta} "comment" = ${Comment} } return $PSO } } <# .SYNOPSIS Convert from JSON to Package<PSCustomObject> .DESCRIPTION Convert from JSON to Package<PSCustomObject> .PARAMETER Json Json object .OUTPUTS Package<PSCustomObject> #> function ConvertFrom-TorizonPlatformAPIJsonToPackage { Param( [AllowEmptyString()] [string]$Json ) Process { 'Converting JSON to PSCustomObject: TorizonPlatformAPI => TorizonPlatformAPIPackage' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json # check if Json contains properties not defined in TorizonPlatformAPIPackage $AllProperties = ("name", "version", "packageId", "size", "hashes", "pkgType", "hardwareIds", "createdAt", "uri", "proprietaryMeta", "comment") 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 'name' missing." } 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 "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 "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 "pkgType"))) { #optional property not found $PkgType = $null } else { $PkgType = $JsonParameters.PSobject.Properties["pkgType"].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 "createdAt"))) { #optional property not found $CreatedAt = $null } else { $CreatedAt = $JsonParameters.PSobject.Properties["createdAt"].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 "proprietaryMeta"))) { #optional property not found $ProprietaryMeta = $null } else { $ProprietaryMeta = $JsonParameters.PSobject.Properties["proprietaryMeta"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "comment"))) { #optional property not found $Comment = $null } else { $Comment = $JsonParameters.PSobject.Properties["comment"].value } $PSO = [PSCustomObject]@{ "name" = ${Name} "version" = ${Version} "packageId" = ${PackageId} "size" = ${Size} "hashes" = ${Hashes} "pkgType" = ${PkgType} "hardwareIds" = ${HardwareIds} "createdAt" = ${CreatedAt} "uri" = ${Uri} "proprietaryMeta" = ${ProprietaryMeta} "comment" = ${Comment} } return $PSO } } |