Model/SiteSharingModel.ps1
|
# # Cloud Governance Api # Contact: support@avepoint.com # <# SiteSharingModel<PSCustomObject> #> function New-SiteSharingModel { [CmdletBinding()] Param ( [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${ExternalSharing} = "Disabled", [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${GuestAccessExpireSetting}, [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${SharingAdvanceSetting}, [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${SharingLinkType} = "SameAsOrganization", [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${AnyoneLinksExpireSetting}, [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${LinkPermissionType} = "SameAsOrganization" ) Process { 'Creating PSCustomObject: Cloud.Governance.Client => SiteSharingModel' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $PSO = [PSCustomObject]@{ "ExternalSharing" = ${ExternalSharing} "GuestAccessExpireSetting" = ${GuestAccessExpireSetting} "SharingAdvanceSetting" = ${SharingAdvanceSetting} "SharingLinkType" = ${SharingLinkType} "AnyoneLinksExpireSetting" = ${AnyoneLinksExpireSetting} "LinkPermissionType" = ${LinkPermissionType} } return $PSO } } <# SiteSharingModel<PSCustomObject> #> function ConvertFrom-JsonToSiteSharingModel { Param( [AllowEmptyString()] [string]$Json ) Process { 'Converting JSON to PSCustomObject: Cloud.Governance.Client => SiteSharingModel' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json # check if Json contains properties not defined in SiteSharingModel $AllProperties = $("ExternalSharing", "GuestAccessExpireSetting", "SharingAdvanceSetting", "SharingLinkType", "AnyoneLinksExpireSetting", "LinkPermissionType") 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 "ExternalSharing"))) { #optional property not found $ExternalSharing = $null } else { $ExternalSharing = $JsonParameters.PSobject.Properties["ExternalSharing"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "GuestAccessExpireSetting"))) { #optional property not found $GuestAccessExpireSetting = $null } else { $GuestAccessExpireSetting = $JsonParameters.PSobject.Properties["GuestAccessExpireSetting"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "SharingAdvanceSetting"))) { #optional property not found $SharingAdvanceSetting = $null } else { $SharingAdvanceSetting = $JsonParameters.PSobject.Properties["SharingAdvanceSetting"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "SharingLinkType"))) { #optional property not found $SharingLinkType = $null } else { $SharingLinkType = $JsonParameters.PSobject.Properties["SharingLinkType"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "AnyoneLinksExpireSetting"))) { #optional property not found $AnyoneLinksExpireSetting = $null } else { $AnyoneLinksExpireSetting = $JsonParameters.PSobject.Properties["AnyoneLinksExpireSetting"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "LinkPermissionType"))) { #optional property not found $LinkPermissionType = $null } else { $LinkPermissionType = $JsonParameters.PSobject.Properties["LinkPermissionType"].value } $PSO = [PSCustomObject]@{ "ExternalSharing" = ${ExternalSharing} "GuestAccessExpireSetting" = ${GuestAccessExpireSetting} "SharingAdvanceSetting" = ${SharingAdvanceSetting} "SharingLinkType" = ${SharingLinkType} "AnyoneLinksExpireSetting" = ${AnyoneLinksExpireSetting} "LinkPermissionType" = ${LinkPermissionType} } return $PSO } } |