Skip to main content

workspace_assignments

Creates, updates, deletes, gets or lists a workspace_assignments resource.

Overview​

Nameworkspace_assignments
TypeResource
Iddatabricks_account.iamv2.workspace_assignments

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
account_idstringThe account ID parent of the workspace where the principal is assigned
principal_idintegerThe internal ID of the principal (user/sp/group) in Databricks.
workspace_idintegerThe workspace ID where the principal is assigned.
effective_entitlementsarrayEvery entitlement the principal holds in this workspace, whether granted directly or through group membership. Get responses populate this field. List responses leave it empty.
entitlementsarrayEntitlements granted directly to the principal on this workspace. This is the only client-settable field. Create and update manage exactly this set, including entitlements the principal also holds through a group. List responses leave this field empty. Get a single principal to read its entitlements.
principal_typestringThe type of the principal (user/service principal/group) that is assigned. (GROUP, SERVICE_PRINCIPAL, USER)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, workspace_id, principal_id, account_hostReturns the assignment for a principal in a workspace.
listselectaccount_id, workspace_id, account_hostpage_size, page_tokenLists workspace assignments for a workspace. The response omits the per-principal entitlement fields
createinsertaccount_id, workspace_id, account_host, principal_idCreates a workspace assignment for a principal. Entitlements are granted one at a time rather than
updateupdateaccount_id, workspace_id, principal_id, update_mask, account_host, principal_idUpdates the entitlements of a directly assigned principal in a workspace. Changes are applied one at a
deletedeleteaccount_id, workspace_id, principal_id, account_hostDeletes a workspace assignment for a principal, revoking all of its entitlements. Entitlements are

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_hoststringThe Databricks account console host. Selected by DATABRICKS_CLOUD (aws, azure or gcp; default aws), or set explicitly with DATABRICKS_ACCOUNT_HOST (bare host, no scheme). (default: accounts.cloud.databricks.com, x-stackQL-envVar: DATABRICKS_ACCOUNT_HOST, x-stackQL-envVarSelector: {"envVar":"DATABRICKS_CLOUD","default":"aws","values":{"aws":"accounts.cloud.databricks.com","azure":"accounts.azuredatabricks.net","gcp":"accounts.gcp.databricks.com"}})
account_idstring
principal_idintegerRequired. ID of the principal in Databricks to delete workspace assignment for.
update_maskobjectRequired. The list of fields to update.
workspace_idintegerThe workspace ID where the principal has access.
page_sizeintegerThe maximum number of workspace assignments to return. The service may return fewer than this value. If not provided, defaults to 1000, which is also the maximum allowed. Requests for more than the maximum are clamped to 1000.
page_tokenstringA page token, received from a previous ListWorkspaceAssignments call. Provide this to retrieve the subsequent page.

SELECT examples​

Returns the assignment for a principal in a workspace.

SELECT
account_id,
principal_id,
workspace_id,
effective_entitlements,
entitlements,
principal_type
FROM databricks_account.iamv2.workspace_assignments
WHERE account_id = '{{ account_id }}' -- required
AND workspace_id = '{{ workspace_id }}' -- required
AND principal_id = '{{ principal_id }}' -- required
AND account_host = '{{ account_host }}' -- required
;

INSERT examples​

Creates a workspace assignment for a principal. Entitlements are granted one at a time rather than

INSERT INTO databricks_account.iamv2.workspace_assignments (
principal_id,
account_id,
effective_entitlements,
entitlements,
principal_type,
workspace_id,
account_id,
workspace_id,
account_host
)
SELECT
{{ principal_id }} /* required */,
'{{ account_id }}',
'{{ effective_entitlements }}',
'{{ entitlements }}',
'{{ principal_type }}',
{{ workspace_id }},
'{{ account_id }}',
{{ workspace_id }},
'{{ account_host }}'
RETURNING
account_id,
principal_id,
workspace_id,
effective_entitlements,
entitlements,
principal_type
;

UPDATE examples​

Updates the entitlements of a directly assigned principal in a workspace. Changes are applied one at a

UPDATE databricks_account.iamv2.workspace_assignments
SET
principal_id = {{ principal_id }},
account_id = '{{ account_id }}',
effective_entitlements = '{{ effective_entitlements }}',
entitlements = '{{ entitlements }}',
principal_type = '{{ principal_type }}',
workspace_id = {{ workspace_id }}
WHERE
account_id = '{{ account_id }}' --required
AND workspace_id = '{{ workspace_id }}' --required
AND principal_id = '{{ principal_id }}' --required
AND update_mask = '{{ update_mask }}' --required
AND account_host = '{{ account_host }}' --required
AND principal_id = '{{ principal_id }}' --required
RETURNING
account_id,
principal_id,
workspace_id,
effective_entitlements,
entitlements,
principal_type;

DELETE examples​

Deletes a workspace assignment for a principal, revoking all of its entitlements. Entitlements are

DELETE FROM databricks_account.iamv2.workspace_assignments
WHERE account_id = '{{ account_id }}' --required
AND workspace_id = '{{ workspace_id }}' --required
AND principal_id = '{{ principal_id }}' --required
AND account_host = '{{ account_host }}' --required
;