Model/DRSiteUrlSetting.ps1

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

<#
DRSiteUrlSetting<PSCustomObject>
#>


function New-DRSiteUrlSetting {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RootSite},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ManagedPath},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Url},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActivityId}
    )

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

        
        $PSO = [PSCustomObject]@{
            "RootSite" = ${RootSite}
            "ManagedPath" = ${ManagedPath}
            "Url" = ${Url}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }
}

<#
DRSiteUrlSetting<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

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

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

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

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

        $PSO = [PSCustomObject]@{
            "RootSite" = ${RootSite}
            "ManagedPath" = ${ManagedPath}
            "Url" = ${Url}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }

}