Public/Workspace.ps1

Function Get-NmeWorkspace {
    <#

    .SYNOPSIS

    Lists all managed workspaces.

    .DESCRIPTION

    ## Notes
- Workspace is considered **managed** if it has at least 1 user assigned
- User assignments can be managed on Users and Roles page.

    This function calls the /api/v1/workspace endpoint of the NME REST API, using the get method.




    #>


    [CmdletBinding()]
    Param(

    )
    Set-NmeAuthHeaders
    Try {
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/workspace$Querystring" -Method get -Headers $script:AuthHeaders -ContentType 'application/json'
        $Result.PSObject.TypeNames.Insert(0, 'NmeArmWorkspace')
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}
Function New-NmeWorkspace {
    <#

    .SYNOPSIS

    Create ARM workspace.

    .DESCRIPTION

    Create ARM workspace.

    This function calls the /api/v1/workspace endpoint of the NME REST API, using the post method.


    .PARAMETER NmeCreateWorkspaceRequest

    Requires an NmeCreateWorkspaceRequest object, as generated by the New-NmeCreateWorkspaceRequest command.

    #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeCreateWorkspaceRequest"){$true} else{throw " is not a NmeCreateWorkspaceRequest object."}})]$NmeCreateWorkspaceRequest
    )
    Set-NmeAuthHeaders
    Try {
        $json = $NmeCreateWorkspaceRequest | ConvertTo-Json -Depth 20
        Write-Debug 'json:'
        Write-Debug $json
        $Result = Invoke-RestMethod "$script:NmeUri/api/v1/workspace$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json
        Write-Verbose ($result | out-string)
        $Result.PSObject.TypeNames.Insert(0, 'NmeResponseWithJobAndArmWorkspace')
        $Result | CapProps
    }
    Catch {
        $message = ParseErrorForResponseBody($_)
        write-error ($message | out-string)
    }
}