Model/LibraryVersionSetting.ps1

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

<#
LibraryVersionSetting<PSCustomObject>
#>


function New-LibraryVersionSetting {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableModeration} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableVersioning} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableMinorVersions} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableMajorVersionLimit} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MajorVersionLimit} = 0,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${EnableMajorWithMinorVersionsLimit} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${MajorWithMinorVersionsLimit} = 0,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActivityId}
    )

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

        
        $PSO = [PSCustomObject]@{
            "EnableModeration" = ${EnableModeration}
            "EnableVersioning" = ${EnableVersioning}
            "EnableMinorVersions" = ${EnableMinorVersions}
            "EnableMajorVersionLimit" = ${EnableMajorVersionLimit}
            "MajorVersionLimit" = ${MajorVersionLimit}
            "EnableMajorWithMinorVersionsLimit" = ${EnableMajorWithMinorVersionsLimit}
            "MajorWithMinorVersionsLimit" = ${MajorWithMinorVersionsLimit}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }
}

<#
LibraryVersionSetting<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in LibraryVersionSetting
        $AllProperties = $("EnableModeration", "EnableVersioning", "EnableMinorVersions", "EnableMajorVersionLimit", "MajorVersionLimit", "EnableMajorWithMinorVersionsLimit", "MajorWithMinorVersionsLimit", "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 "EnableModeration"))) { #optional property not found
            $EnableModeration = $null
        } else {
            $EnableModeration = $JsonParameters.PSobject.Properties["EnableModeration"].value
        }

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "EnableModeration" = ${EnableModeration}
            "EnableVersioning" = ${EnableVersioning}
            "EnableMinorVersions" = ${EnableMinorVersions}
            "EnableMajorVersionLimit" = ${EnableMajorVersionLimit}
            "MajorVersionLimit" = ${MajorVersionLimit}
            "EnableMajorWithMinorVersionsLimit" = ${EnableMajorWithMinorVersionsLimit}
            "MajorWithMinorVersionsLimit" = ${MajorWithMinorVersionsLimit}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }

}