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:

NameDatatypeDescription
namestringIdentifier. Resource name of this data policy, in the format of projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}.
dataMaskingPolicyobjectOptional. The data masking policy that specifies the data masking rule to use. It must be set if the data policy type is DATA_MASKING_POLICY. (id: DataMaskingPolicy)
dataPolicyIdstringOutput only. User-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. Type of data policy.
etagstringThe etag for this Data Policy. This field is used for UpdateDataPolicy calls. If Data Policy exists, this field is required and must match the server's etag. It will also be populated in the response of GetDataPolicy, CreateDataPolicy, and UpdateDataPolicy calls.
granteesarrayOptional. The list of IAM principals that have Fine Grained Access to the underlying data goverened by this data policy. Uses the IAM V2 principal syntax Only supports principal types users, groups, serviceaccounts, cloudidentity. This field is supported in V2 Data Policy only. In case of V1 data policies (i.e. verion = 1 and policy_tag is set), this field is not populated.
policyTagstringOutput only. Policy tag resource name, in the format of projects/{project_number}/locations/{location_id}/taxonomies/{taxonomy_id}/policyTags/{policyTag_id}. policy_tag is supported only for V1 data policies.
versionstringOutput only. The version of the Data Policy resource.

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 data_policy_id (used as the display name), 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, dataPoliciesIdDeletes the data policy specified by its resource name.

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
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Gets the data policy specified by its resource name.

SELECT
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
etag,
grantees,
policyTag,
version
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 data_policy_id (used as the display name), and data policy type.

INSERT INTO google.bigquerydatapolicy.data_policies (
data__dataPolicyId,
data__dataPolicy,
projectsId,
locationsId
)
SELECT
'{{ dataPolicyId }}',
'{{ dataPolicy }}',
'{{ projectsId }}',
'{{ locationsId }}'
RETURNING
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
etag,
grantees,
policyTag,
version
;

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__dataMaskingPolicy = '{{ dataMaskingPolicy }}',
data__name = '{{ name }}',
data__etag = '{{ etag }}',
data__dataPolicyType = '{{ dataPolicyType }}',
data__grantees = '{{ grantees }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND dataPoliciesId = '{{ dataPoliciesId }}' --required
AND updateMask = '{{ updateMask}}'
AND allowMissing = {{ allowMissing}}
RETURNING
name,
dataMaskingPolicy,
dataPolicyId,
dataPolicyType,
etag,
grantees,
policyTag,
version;

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
;