Skip to main content

policies

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

Overview

Namepolicies
TypeResource
Idgoogle.orgpolicy.policies

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringImmutable. The resource name of the policy. Must be one of the following forms, where constraint_name is the name of the constraint which this policy configures: * projects/{project_number}/policies/{constraint_name} * folders/{folder_id}/policies/{constraint_name} * organizations/{organization_id}/policies/{constraint_name} For example, projects/123/policies/compute.disableSerialPortAccess. Note: projects/{project_id}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.
alternateobjectDeprecated. (id: GoogleCloudOrgpolicyV2AlternatePolicySpec)
dryRunSpecobjectDry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced. (id: GoogleCloudOrgpolicyV2PolicySpec)
etagstringOptional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
specobjectBasic information about the organization policy. (id: GoogleCloudOrgpolicyV2PolicySpec)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
projects_policies_getselectprojectsId, policiesIdGets a policy on a resource. If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.
folders_policies_getselectfoldersId, policiesIdGets a policy on a resource. If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.
organizations_policies_getselectorganizationsId, policiesIdGets a policy on a resource. If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.
projects_policies_listselectprojectsIdpageSize, pageTokenRetrieves all of the policies that exist on a particular resource.
folders_policies_listselectfoldersIdpageSize, pageTokenRetrieves all of the policies that exist on a particular resource.
organizations_policies_listselectorganizationsIdpageSize, pageTokenRetrieves all of the policies that exist on a particular resource.
projects_policies_createinsertprojectsIdCreates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.
folders_policies_createinsertfoldersIdCreates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.
organizations_policies_createinsertorganizationsIdCreates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.
projects_policies_patchupdateprojectsId, policiesIdupdateMaskUpdates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
folders_policies_patchupdatefoldersId, policiesIdupdateMaskUpdates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
organizations_policies_patchupdateorganizationsId, policiesIdupdateMaskUpdates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
projects_policies_deletedeleteprojectsId, policiesIdetagDeletes a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.
folders_policies_deletedeletefoldersId, policiesIdetagDeletes a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.
organizations_policies_deletedeleteorganizationsId, policiesIdetagDeletes a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

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
foldersIdstring
organizationsIdstring
policiesIdstring
projectsIdstring
etagstring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Gets a policy on a resource. If no policy is set on the resource, NOT_FOUND is returned. The etag value can be used with UpdatePolicy() to update a policy during read-modify-write.

SELECT
name,
alternate,
dryRunSpec,
etag,
spec
FROM google.orgpolicy.policies
WHERE projectsId = '{{ projectsId }}' -- required
AND policiesId = '{{ policiesId }}' -- required;

INSERT examples

Creates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint does not exist. Returns a google.rpc.Status with google.rpc.Code.ALREADY_EXISTS if the policy already exists on the given Google Cloud resource.

INSERT INTO google.orgpolicy.policies (
data__name,
data__spec,
data__alternate,
data__dryRunSpec,
data__etag,
projectsId
)
SELECT
'{{ name }}',
'{{ spec }}',
'{{ alternate }}',
'{{ dryRunSpec }}',
'{{ etag }}',
'{{ projectsId }}'
RETURNING
name,
alternate,
dryRunSpec,
etag,
spec
;

UPDATE examples

Updates a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or the policy do not exist. Returns a google.rpc.Status with google.rpc.Code.ABORTED if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.

UPDATE google.orgpolicy.policies
SET
data__name = '{{ name }}',
data__spec = '{{ spec }}',
data__alternate = '{{ alternate }}',
data__dryRunSpec = '{{ dryRunSpec }}',
data__etag = '{{ etag }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND policiesId = '{{ policiesId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
alternate,
dryRunSpec,
etag,
spec;

DELETE examples

Deletes a policy. Returns a google.rpc.Status with google.rpc.Code.NOT_FOUND if the constraint or organization policy does not exist.

DELETE FROM google.orgpolicy.policies
WHERE projectsId = '{{ projectsId }}' --required
AND policiesId = '{{ policiesId }}' --required
AND etag = '{{ etag }}';