Model/SASUriModel.ps1

#
# Cloud Governance Api
# Contact: support@avepoint.com
#

<#
SASUriModel<PSCustomObject>
#>


function New-SASUriModel {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Uri},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${FileName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int64]]
        ${ExpiredTime} = 0
    )

    Process {
        'Creating PSCustomObject: Cloud.Governance.Client => SASUriModel' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        
        $PSO = [PSCustomObject]@{
            "Uri" = ${Uri}
            "FileName" = ${FileName}
            "ExpiredTime" = ${ExpiredTime}
        }

        return $PSO
    }
}

<#
SASUriModel<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in SASUriModel
        $AllProperties = $("Uri", "FileName", "ExpiredTime")
        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 "Uri"))) { #optional property not found
            $Uri = $null
        } else {
            $Uri = $JsonParameters.PSobject.Properties["Uri"].value
        }

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

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

        $PSO = [PSCustomObject]@{
            "Uri" = ${Uri}
            "FileName" = ${FileName}
            "ExpiredTime" = ${ExpiredTime}
        }

        return $PSO
    }

}