Skip to main content

data_policies

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

Overview

Namedata_policies
TypeResource
Idgoogle.bigquerydatapolicy.data_policies

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. Resource name of this data policy, in the format of projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}.
dataMaskingPolicyobjectThe data masking policy that specifies the data masking rule to use. (id: DataMaskingPolicy)
dataPolicyIdstringUser-assigned (human readable) ID of the data policy that needs to be unique within a project. Used as {data_policy_id} in part of the resource name.
dataPolicyTypestringRequired. Data policy type. Type of data policy.
policyTagstringPolicy tag resource name, in the format of projects/{project_number}/locations/{location_id}/taxonomies/{taxonomy_id}/policyTags/{policyTag_id}.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, dataPoliciesIdGets the data policy specified by its resource name.
listselectprojectsId, locationsIdpageSize, pageToken, filterList all of the data policies in the specified parent project.
createinsertprojectsId, locationsIdCreates a new data policy under a project with the given dataPolicyId (used as the display name), policy tag, and data policy type.
patchupdateprojectsId, locationsId, dataPoliciesIdupdateMask, allowMissingUpdates the metadata for an existing data policy. The target data policy can be specified by the resource name.
deletedeleteprojectsId, locationsId, dataPoliciesIdforceDeletes the data policy specified by its resource name.
renameexecprojectsId, locationsId, dataPoliciesIdRenames the id (display name) of the specified data policy.

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
dataPoliciesIdstring
locationsIdstring
projectsIdstring
allowMissingboolean
filterstring
forceboolean
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Gets the data policy specified by its resource name.

SELECT
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
policyTag
FROM google.bigquerydatapolicy.data_policies
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND dataPoliciesId = '{{ dataPoliciesId }}' -- required;

INSERT examples

Creates a new data policy under a project with the given dataPolicyId (used as the display name), policy tag, and data policy type.

INSERT INTO google.bigquerydatapolicy.data_policies (
data__policyTag,
data__dataMaskingPolicy,
data__dataPolicyType,
data__dataPolicyId,
projectsId,
locationsId
)
SELECT
'{{ policyTag }}',
'{{ dataMaskingPolicy }}',
'{{ dataPolicyType }}',
'{{ dataPolicyId }}',
'{{ projectsId }}',
'{{ locationsId }}'
RETURNING
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
policyTag
;

UPDATE examples

Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

UPDATE google.bigquerydatapolicy.data_policies
SET
data__policyTag = '{{ policyTag }}',
data__dataMaskingPolicy = '{{ dataMaskingPolicy }}',
data__dataPolicyType = '{{ dataPolicyType }}',
data__dataPolicyId = '{{ dataPolicyId }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND dataPoliciesId = '{{ dataPoliciesId }}' --required
AND updateMask = '{{ updateMask}}'
AND allowMissing = {{ allowMissing}}
RETURNING
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
policyTag;

DELETE examples

Deletes the data policy specified by its resource name.

DELETE FROM google.bigquerydatapolicy.data_policies
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND dataPoliciesId = '{{ dataPoliciesId }}' --required
AND force = '{{ force }}';

Lifecycle Methods

Renames the id (display name) of the specified data policy.

EXEC google.bigquerydatapolicy.data_policies.rename 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@dataPoliciesId='{{ dataPoliciesId }}' --required
@@json=
'{
"newDataPolicyId": "{{ newDataPolicyId }}"
}';