Model/GuestPermissions.ps1

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

<#
GuestPermissions<PSCustomObject>
#>


function New-GuestPermissions {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${AllowGuestsCreateUpdateChannels} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${AllowGuestsDeleteChannels} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${OriginalAllowGuestsCreateUpdateChannels} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${OriginalAllowGuestsDeleteChannels} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ActivityId}
    )

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

        
        $PSO = [PSCustomObject]@{
            "AllowGuestsCreateUpdateChannels" = ${AllowGuestsCreateUpdateChannels}
            "AllowGuestsDeleteChannels" = ${AllowGuestsDeleteChannels}
            "OriginalAllowGuestsCreateUpdateChannels" = ${OriginalAllowGuestsCreateUpdateChannels}
            "OriginalAllowGuestsDeleteChannels" = ${OriginalAllowGuestsDeleteChannels}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }
}

<#
GuestPermissions<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "AllowGuestsCreateUpdateChannels" = ${AllowGuestsCreateUpdateChannels}
            "AllowGuestsDeleteChannels" = ${AllowGuestsDeleteChannels}
            "OriginalAllowGuestsCreateUpdateChannels" = ${OriginalAllowGuestsCreateUpdateChannels}
            "OriginalAllowGuestsDeleteChannels" = ${OriginalAllowGuestsDeleteChannels}
            "ActivityId" = ${ActivityId}
        }

        return $PSO
    }

}