Skip to main content

policies

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

Overview

Namepolicies
TypeResource
Iddatabricks_workspace.catalog.policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUnique identifier of the policy. This field is output only and is generated by the system.
namestringName of the policy. Required on create and optional on update. To rename the policy, set `name` to a different value on update.
column_maskobjectOptions for column mask policies. Valid only if `policy_type` is `POLICY_TYPE_COLUMN_MASK`. Required on create and optional on update. When specified on update, the new options will replace the existing options as a whole.
commentstringOptional description of the policy.
created_atintegerTime at which the policy was created, in epoch milliseconds. Output only.
created_bystringUsername of the user who created the policy. Output only.
except_principalsarrayOptional list of user or group names that should be excluded from the policy.
for_securable_typestringThe type of Unity Catalog securable. (CATALOG, CLEAN_ROOM, CONNECTION, CREDENTIAL, EXTERNAL_LOCATION, EXTERNAL_METADATA, FUNCTION, METASTORE, PIPELINE, PROVIDER, RECIPIENT, SCHEMA, SHARE, STAGING_TABLE, STORAGE_CREDENTIAL, TABLE, VOLUME)
match_columnsarrayOptional list of condition expressions used to match table columns. Only valid when `for_securable_type` is `TABLE`. When specified, the policy only applies to tables whose columns satisfy all match conditions.
on_securable_fullnamestringFull name of the securable on which the policy is defined. Required on create.
on_securable_typestringThe type of Unity Catalog securable. (CATALOG, CLEAN_ROOM, CONNECTION, CREDENTIAL, EXTERNAL_LOCATION, EXTERNAL_METADATA, FUNCTION, METASTORE, PIPELINE, PROVIDER, RECIPIENT, SCHEMA, SHARE, STAGING_TABLE, STORAGE_CREDENTIAL, TABLE, VOLUME)
policy_typestringType of the policy. Required on create. (POLICY_TYPE_COLUMN_MASK, POLICY_TYPE_ROW_FILTER)
row_filterobjectOptions for row filter policies. Valid only if `policy_type` is `POLICY_TYPE_ROW_FILTER`. Required on create and optional on update. When specified on update, the new options will replace the existing options as a whole.
to_principalsarray
updated_atintegerTime at which the policy was last modified, in epoch milliseconds. Output only.
updated_bystringUsername of the user who last modified the policy. Output only.
when_conditionstringOptional condition when the policy should take effect.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselecton_securable_type, on_securable_fullname, name, deployment_nameGet the policy definition on a securable
listselecton_securable_type, on_securable_fullname, deployment_nameinclude_inherited, max_results, page_tokenList all policies defined on a securable. Optionally, the list can include inherited policies defined
createinsertdeployment_name, policy_infoCreates a new policy on a securable. The new policy applies to the securable and all its descendants.
updateupdateon_securable_type, on_securable_fullname, name, deployment_name, policy_infoupdate_maskUpdate an ABAC policy on a securable.
deletedeleteon_securable_type, on_securable_fullname, name, deployment_nameDelete an ABAC policy defined on a securable.

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
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
namestringRequired. The name of the policy to delete
on_securable_fullnamestringRequired. The fully qualified name of the securable to delete the policy from.
on_securable_typestringRequired. The type of the securable to delete the policy from.
include_inheritedbooleanOptional. Whether to include policies defined on parent securables. By default, the inherited policies are not included.
max_resultsintegerOptional. Maximum number of policies to return on a single page (page length). - When not set or set to 0, the page length is set to a server configured value (recommended); - When set to a value greater than 0, the page length is the minimum of this value and a server configured value;
page_tokenstringOptional. Opaque pagination token to go to next page based on previous query.
update_maskstringOptional. The update mask field for specifying user intentions on which fields to update in the request.

SELECT examples

Get the policy definition on a securable

SELECT
id,
name,
column_mask,
comment,
created_at,
created_by,
except_principals,
for_securable_type,
match_columns,
on_securable_fullname,
on_securable_type,
policy_type,
row_filter,
to_principals,
updated_at,
updated_by,
when_condition
FROM databricks_workspace.catalog.policies
WHERE on_securable_type = '{{ on_securable_type }}' -- required
AND on_securable_fullname = '{{ on_securable_fullname }}' -- required
AND name = '{{ name }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
;

INSERT examples

Creates a new policy on a securable. The new policy applies to the securable and all its descendants.

INSERT INTO databricks_workspace.catalog.policies (
policy_info,
deployment_name
)
SELECT
'{{ policy_info }}' /* required */,
'{{ deployment_name }}'
RETURNING
id,
name,
column_mask,
comment,
created_at,
created_by,
except_principals,
for_securable_type,
match_columns,
on_securable_fullname,
on_securable_type,
policy_type,
row_filter,
to_principals,
updated_at,
updated_by,
when_condition
;

UPDATE examples

Update an ABAC policy on a securable.

UPDATE databricks_workspace.catalog.policies
SET
policy_info = '{{ policy_info }}'
WHERE
on_securable_type = '{{ on_securable_type }}' --required
AND on_securable_fullname = '{{ on_securable_fullname }}' --required
AND name = '{{ name }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND policy_info = '{{ policy_info }}' --required
AND update_mask = '{{ update_mask}}'
RETURNING
id,
name,
column_mask,
comment,
created_at,
created_by,
except_principals,
for_securable_type,
match_columns,
on_securable_fullname,
on_securable_type,
policy_type,
row_filter,
to_principals,
updated_at,
updated_by,
when_condition;

DELETE examples

Delete an ABAC policy defined on a securable.

DELETE FROM databricks_workspace.catalog.policies
WHERE on_securable_type = '{{ on_securable_type }}' --required
AND on_securable_fullname = '{{ on_securable_fullname }}' --required
AND name = '{{ name }}' --required
AND deployment_name = '{{ deployment_name }}' --required
;