Reference documentation and code samples for the Google Cloud Org Policy V2 Client class Policy.
Defines an organization policy which is used to specify constraints
for configurations of Google Cloud resources.
Generated from protobuf messagegoogle.cloud.orgpolicy.v2.Policy
Namespace
Google \ Cloud \ OrgPolicy \ V2
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ name
string
Immutable. The resource name of the policy. Must be one of the following forms, whereconstraint_nameis 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.
Dry-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.
↳ etag
string
Optional. 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.
getName
Immutable. The resource name of the policy. Must be one of the following
forms, whereconstraint_nameis the name of the constraint which this
policy configures:
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.
Returns
Type
Description
string
setName
Immutable. The resource name of the policy. Must be one of the following
forms, whereconstraint_nameis the name of the constraint which this
policy configures:
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.
Optional. 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.
Returns
Type
Description
string
setEtag
Optional. 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Org Policy V2 Client - Class Policy (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-org-policy/latest/V2.Policy)\n- [1.2.1](/php/docs/reference/cloud-org-policy/1.2.1/V2.Policy)\n- [1.1.3](/php/docs/reference/cloud-org-policy/1.1.3/V2.Policy)\n- [1.0.0](/php/docs/reference/cloud-org-policy/1.0.0/V2.Policy)\n- [0.7.0](/php/docs/reference/cloud-org-policy/0.7.0/V2.Policy)\n- [0.6.5](/php/docs/reference/cloud-org-policy/0.6.5/V2.Policy)\n- [0.5.3](/php/docs/reference/cloud-org-policy/0.5.3/V2.Policy)\n- [0.4.2](/php/docs/reference/cloud-org-policy/0.4.2/V2.Policy)\n- [0.3.7](/php/docs/reference/cloud-org-policy/0.3.7/V2.Policy) \nReference documentation and code samples for the Google Cloud Org Policy V2 Client class Policy.\n\nDefines an organization policy which is used to specify constraints\nfor configurations of Google Cloud resources.\n\nGenerated from protobuf message `google.cloud.orgpolicy.v2.Policy`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ OrgPolicy \\\\ V2\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getName\n\nImmutable. The resource name of the policy. Must be one of the following\nforms, where `constraint_name` is the name of the constraint which this\npolicy configures:\n\n- `projects/{project_number}/policies/{constraint_name}`\n- `folders/{folder_id}/policies/{constraint_name}`\n- `organizations/{organization_id}/policies/{constraint_name}` For example, `projects/123/policies/compute.disableSerialPortAccess`.\n\nNote: `projects/{project_id}/policies/{constraint_name}` is also an\nacceptable name for API requests, but responses will return the name using\nthe equivalent project number.\n\n### setName\n\nImmutable. The resource name of the policy. Must be one of the following\nforms, where `constraint_name` is the name of the constraint which this\npolicy configures:\n\n- `projects/{project_number}/policies/{constraint_name}`\n- `folders/{folder_id}/policies/{constraint_name}`\n- `organizations/{organization_id}/policies/{constraint_name}` For example, `projects/123/policies/compute.disableSerialPortAccess`.\n\nNote: `projects/{project_id}/policies/{constraint_name}` is also an\nacceptable name for API requests, but responses will return the name using\nthe equivalent project number.\n\n### getSpec\n\nBasic information about the organization policy.\n\n### hasSpec\n\n### clearSpec\n\n### setSpec\n\nBasic information about the organization policy.\n\n### getAlternate\n\nDeprecated.\n\n### hasAlternate\n\n### clearAlternate\n\n### setAlternate\n\nDeprecated.\n\n### getDryRunSpec\n\nDry-run policy.\n\nAudit-only policy, can be used to monitor how the policy would have\nimpacted the existing and future resources if it's enforced.\n\n### hasDryRunSpec\n\n### clearDryRunSpec\n\n### setDryRunSpec\n\nDry-run policy.\n\nAudit-only policy, can be used to monitor how the policy would have\nimpacted the existing and future resources if it's enforced.\n\n### getEtag\n\nOptional. An opaque tag indicating the current state of the policy, used\nfor concurrency control. This 'etag' is computed by the server based on the\nvalue of other fields, and may be sent on update and delete requests to\nensure the client has an up-to-date value before proceeding.\n\n### setEtag\n\nOptional. An opaque tag indicating the current state of the policy, used\nfor concurrency control. This 'etag' is computed by the server based on the\nvalue of other fields, and may be sent on update and delete requests to\nensure the client has an up-to-date value before proceeding."]]