Model/UserMembershipInfo.ps1

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

<#
UserMembershipInfo<PSCustomObject>
#>


function New-UserMembershipInfo {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ObjectId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${IdentityName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DisplayName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${UserType} = "User",
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${ActionType} = "None"
    )

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

        
        $PSO = [PSCustomObject]@{
            "ObjectId" = ${ObjectId}
            "IdentityName" = ${IdentityName}
            "DisplayName" = ${DisplayName}
            "UserType" = ${UserType}
            "ActionType" = ${ActionType}
        }

        return $PSO
    }
}

<#
UserMembershipInfo<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in UserMembershipInfo
        $AllProperties = $("ObjectId", "IdentityName", "DisplayName", "UserType", "ActionType")
        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 "ObjectId"))) { #optional property not found
            $ObjectId = $null
        } else {
            $ObjectId = $JsonParameters.PSobject.Properties["ObjectId"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "ObjectId" = ${ObjectId}
            "IdentityName" = ${IdentityName}
            "DisplayName" = ${DisplayName}
            "UserType" = ${UserType}
            "ActionType" = ${ActionType}
        }

        return $PSO
    }

}