Reference documentation and code samples for the Google Cloud Org Policy V2 Client class Constraint.
A constraint describes a way to restrict resource's configuration. For
example, you could enforce a constraint that controls which Google Cloud
services can be activated across an organization, or whether a Compute Engine
instance can have serial port connections established. Constraints can be
configured by the organization policy administrator to fit the needs of the
organization by setting a policy that includes constraints at different
locations in the organization's resource hierarchy. Policies are inherited
down the resource hierarchy from higher levels, but can also be overridden.
For details about the inheritance rules, seePolicy.
Constraints have a default behavior determined by theconstraint_defaultfield, which is the enforcement behavior that is used in the absence of a
policy being defined or inherited for the resource in question.
Generated from protobuf messagegoogle.cloud.orgpolicy.v2.Constraint
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 constraint. Must be in one of the following forms: * *projects/{project_number}/constraints/{constraint_name}* *folders/{folder_id}/constraints/{constraint_name}* *organizations/{organization_id}/constraints/{constraint_name}For example, "/projects/123/constraints/compute.disableSerialPortAccess".
↳ display_name
string
The human readable name. Mutable.
↳ description
string
Detailed description of what this constraint controls as well as how and where it is enforced. Mutable.
↳ constraint_default
int
The evaluation behavior of this constraint in the absence of a policy.
[[["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 Constraint (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-org-policy/latest/V2.Constraint)\n- [1.2.1](/php/docs/reference/cloud-org-policy/1.2.1/V2.Constraint)\n- [1.1.3](/php/docs/reference/cloud-org-policy/1.1.3/V2.Constraint)\n- [1.0.0](/php/docs/reference/cloud-org-policy/1.0.0/V2.Constraint)\n- [0.7.0](/php/docs/reference/cloud-org-policy/0.7.0/V2.Constraint)\n- [0.6.5](/php/docs/reference/cloud-org-policy/0.6.5/V2.Constraint)\n- [0.5.3](/php/docs/reference/cloud-org-policy/0.5.3/V2.Constraint)\n- [0.4.2](/php/docs/reference/cloud-org-policy/0.4.2/V2.Constraint)\n- [0.3.7](/php/docs/reference/cloud-org-policy/0.3.7/V2.Constraint) \nReference documentation and code samples for the Google Cloud Org Policy V2 Client class Constraint.\n\nA constraint describes a way to restrict resource's configuration. For\nexample, you could enforce a constraint that controls which Google Cloud\nservices can be activated across an organization, or whether a Compute Engine\ninstance can have serial port connections established. Constraints can be\nconfigured by the organization policy administrator to fit the needs of the\norganization by setting a policy that includes constraints at different\nlocations in the organization's resource hierarchy. Policies are inherited\ndown the resource hierarchy from higher levels, but can also be overridden.\n\nFor details about the inheritance rules, see\n[`Policy`](/php/docs/reference/cloud-org-policy/latest/V2.Policy).\nConstraints have a default behavior determined by the `constraint_default`\nfield, which is the enforcement behavior that is used in the absence of a\npolicy being defined or inherited for the resource in question.\n\nGenerated from protobuf message `google.cloud.orgpolicy.v2.Constraint`\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 constraint. Must be in one of\nthe following forms:\n\n- `projects/{project_number}/constraints/{constraint_name}`\n- `folders/{folder_id}/constraints/{constraint_name}`\n- `organizations/{organization_id}/constraints/{constraint_name}` For example, \"/projects/123/constraints/compute.disableSerialPortAccess\".\n\n### setName\n\nImmutable. The resource name of the constraint. Must be in one of\nthe following forms:\n\n- `projects/{project_number}/constraints/{constraint_name}`\n- `folders/{folder_id}/constraints/{constraint_name}`\n- `organizations/{organization_id}/constraints/{constraint_name}` For example, \"/projects/123/constraints/compute.disableSerialPortAccess\".\n\n### getDisplayName\n\nThe human readable name.\n\nMutable.\n\n### setDisplayName\n\nThe human readable name.\n\nMutable.\n\n### getDescription\n\nDetailed description of what this constraint controls as well as how and\nwhere it is enforced.\n\nMutable.\n\n### setDescription\n\nDetailed description of what this constraint controls as well as how and\nwhere it is enforced.\n\nMutable.\n\n### getConstraintDefault\n\nThe evaluation behavior of this constraint in the absence of a policy.\n\n### setConstraintDefault\n\nThe evaluation behavior of this constraint in the absence of a policy.\n\n### getListConstraint\n\nDefines this constraint as being a list constraint.\n\n### hasListConstraint\n\n### setListConstraint\n\nDefines this constraint as being a list constraint.\n\n### getBooleanConstraint\n\nDefines this constraint as being a boolean constraint.\n\n### hasBooleanConstraint\n\n### setBooleanConstraint\n\nDefines this constraint as being a boolean constraint.\n\n### getSupportsDryRun\n\nShows if dry run is supported for this constraint or not.\n\n### setSupportsDryRun\n\nShows if dry run is supported for this constraint or not.\n\n### getEquivalentConstraint\n\nManaged constraint and canned constraint sometimes can have\nequivalents. This field is used to store the equivalent constraint name.\n\n### setEquivalentConstraint\n\nManaged constraint and canned constraint sometimes can have\nequivalents. This field is used to store the equivalent constraint name.\n\n### getSupportsSimulation\n\nShows if simulation is supported for this constraint or not.\n\n### setSupportsSimulation\n\nShows if simulation is supported for this constraint or not.\n\n### getConstraintType"]]