Skip to main content

policies

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

Overview​

Namepolicies
TypeResource
Idgoogle.iamv2beta.policies

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringImmutable. The resource name of the Policy, which must be unique. Format: policies/{attachment_point}/denypolicies/{policy_id} The attachment point is identified by its URL-encoded full resource name, which means that the forward-slash character, /, must be written as %2F. For example, policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-deny-policy. For organizations and folders, use the numeric ID in the full resource name. For projects, requests can use the alphanumeric or the numeric ID. Responses always contain the numeric ID.
annotationsobjectA key-value map to store arbitrary metadata for the Policy. Keys can be up to 63 characters. Values can be up to 255 characters.
createTimestring (google-datetime)Output only. The time when the Policy was created.
deleteTimestring (google-datetime)Output only. The time when the Policy was deleted. Empty if the policy is not deleted.
displayNamestringA user-specified description of the Policy. This value can be up to 63 characters.
etagstringAn opaque tag that identifies the current version of the Policy. IAM uses this value to help manage concurrent updates, so they do not cause one update to be overwritten by another. If this field is present in a CreatePolicyRequest, the value is ignored.
kindstringOutput only. The kind of the Policy. Always contains the value DenyPolicy.
rulesarrayA list of rules that specify the behavior of the Policy. All of the rules should be of the kind specified in the Policy.
uidstringImmutable. The globally unique ID of the Policy. Assigned automatically when the Policy is created.
updateTimestring (google-datetime)Output only. The time when the Policy was last updated.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectpoliciesId, policiesId1, policiesId2Gets a policy.
list_policiesselectpoliciesId, policiesId1pageSize, pageTokenRetrieves the policies of the specified kind that are attached to a resource. The response lists only policy metadata. In particular, policy rules are omitted.
create_policyinsertpoliciesId, policiesId1policyIdCreates a policy.
updatereplacepoliciesId, policiesId1, policiesId2Updates the specified policy. You can update only the rules and the display name for the policy. To update a policy, you should use a read-modify-write loop: 1. Use GetPolicy to read the current version of the policy. 2. Modify the policy as needed. 3. Use UpdatePolicy to write the updated policy. This pattern helps prevent conflicts between concurrent updates.
deletedeletepoliciesId, policiesId1, policiesId2etagDeletes a policy. This action is permanent.

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
policiesIdstring
policiesId1string
policiesId2string
etagstring
pageSizeinteger (int32)
pageTokenstring
policyIdstring

SELECT examples​

Gets a policy.

SELECT
name,
annotations,
createTime,
deleteTime,
displayName,
etag,
kind,
rules,
uid,
updateTime
FROM google.iamv2beta.policies
WHERE policiesId = '{{ policiesId }}' -- required
AND policiesId1 = '{{ policiesId1 }}' -- required
AND policiesId2 = '{{ policiesId2 }}' -- required
;

INSERT examples​

Creates a policy.

INSERT INTO google.iamv2beta.policies (
data__annotations,
data__displayName,
data__etag,
data__name,
data__rules,
data__uid,
policiesId,
policiesId1,
policyId
)
SELECT
'{{ annotations }}',
'{{ displayName }}',
'{{ etag }}',
'{{ name }}',
'{{ rules }}',
'{{ uid }}',
'{{ policiesId }}',
'{{ policiesId1 }}',
'{{ policyId }}'
RETURNING
name,
done,
error,
metadata,
response
;

REPLACE examples​

Updates the specified policy. You can update only the rules and the display name for the policy. To update a policy, you should use a read-modify-write loop: 1. Use GetPolicy to read the current version of the policy. 2. Modify the policy as needed. 3. Use UpdatePolicy to write the updated policy. This pattern helps prevent conflicts between concurrent updates.

REPLACE google.iamv2beta.policies
SET
data__annotations = '{{ annotations }}',
data__displayName = '{{ displayName }}',
data__etag = '{{ etag }}',
data__name = '{{ name }}',
data__rules = '{{ rules }}',
data__uid = '{{ uid }}'
WHERE
policiesId = '{{ policiesId }}' --required
AND policiesId1 = '{{ policiesId1 }}' --required
AND policiesId2 = '{{ policiesId2 }}' --required
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples​

Deletes a policy. This action is permanent.

DELETE FROM google.iamv2beta.policies
WHERE policiesId = '{{ policiesId }}' --required
AND policiesId1 = '{{ policiesId1 }}' --required
AND policiesId2 = '{{ policiesId2 }}' --required
AND etag = '{{ etag }}'
;