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, see
[Policy][google.cloud.orgpolicy.v2.Policy].
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.
This message hasoneof_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
A custom constraint defined by customers which canonlybe applied
to the given resource types and organization.
By creating a custom constraint, customers can apply policies of
this custom constraint.Creating a custom constraint itself does
NOT apply any policy enforcement.
The response returned from the [ListCustomConstraints]
[google.cloud.orgpolicy.v2.OrgPolicy.ListCustomConstraints] method.
It will be empty if no custom or managed constraints are set on the
organization resource.
The response returned from the [ListPolicies]
[google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will
be empty if no policies are set on the resource.
[[["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,["# Package types (1.14.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.14.0 (latest)](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types)\n- [1.13.0](/python/docs/reference/orgpolicy/1.13.0/google.cloud.orgpolicy_v2.types)\n- [1.12.0](/python/docs/reference/orgpolicy/1.12.0/google.cloud.orgpolicy_v2.types)\n- [1.11.1](/python/docs/reference/orgpolicy/1.11.1/google.cloud.orgpolicy_v2.types)\n- [1.10.0](/python/docs/reference/orgpolicy/1.10.0/google.cloud.orgpolicy_v2.types)\n- [1.9.0](/python/docs/reference/orgpolicy/1.9.0/google.cloud.orgpolicy_v2.types)\n- [1.8.3](/python/docs/reference/orgpolicy/1.8.3/google.cloud.orgpolicy_v2.types)\n- [1.7.1](/python/docs/reference/orgpolicy/1.7.1/google.cloud.orgpolicy_v2.types)\n- [1.6.0](/python/docs/reference/orgpolicy/1.6.0/google.cloud.orgpolicy_v2.types)\n- [1.5.0](/python/docs/reference/orgpolicy/1.5.0/google.cloud.orgpolicy_v2.types)\n- [1.4.1](/python/docs/reference/orgpolicy/1.4.1/google.cloud.orgpolicy_v2.types)\n- [1.3.3](/python/docs/reference/orgpolicy/1.3.3/google.cloud.orgpolicy_v2.types)\n- [1.2.1](/python/docs/reference/orgpolicy/1.2.1/google.cloud.orgpolicy_v2.types)\n- [1.1.0](/python/docs/reference/orgpolicy/1.1.0/google.cloud.orgpolicy_v2.types)\n- [1.0.2](/python/docs/reference/orgpolicy/1.0.2/google.cloud.orgpolicy_v2.types)\n- [0.3.0](/python/docs/reference/orgpolicy/0.3.0/google.cloud.orgpolicy_v2.types)\n- [0.2.0](/python/docs/reference/orgpolicy/0.2.0/google.cloud.orgpolicy_v2.types)\n- [0.1.2](/python/docs/reference/orgpolicy/0.1.2/google.cloud.orgpolicy_v2.types) \nAPI documentation for `orgpolicy_v2.types` package. \n\nClasses\n-------\n\n### [AlternatePolicySpec](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.AlternatePolicySpec)\n\nSimilar to PolicySpec but with an extra 'launch' field for\nlaunch reference. The PolicySpec here is specific for dry-run.\n\n### [Constraint](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.Constraint)\n\nA constraint describes a way to restrict resource's configuration.\nFor example, you could enforce a constraint that controls which\nGoogle Cloud services can be activated across an organization, or\nwhether a Compute Engine instance can have serial port connections\nestablished. Constraints can be configured by the organization\npolicy administrator to fit the needs of the organization by setting\na policy that includes constraints at different locations in the\norganization's resource hierarchy. Policies are inherited down the\nresource hierarchy from higher levels, but can also be overridden.\nFor details about the inheritance rules, see\n\\[`Policy`\\]\\[google.cloud.orgpolicy.v2.Policy\\].\n\nConstraints have a default behavior determined by the\n`constraint_default` field, which is the enforcement behavior that\nis used in the absence of a policy being defined or inherited for\nthe resource in question.\n\nThis message has `oneof`_ fields (mutually exclusive fields).\nFor each oneof, at most one member field can be set at the same time.\nSetting any member of the oneof automatically clears all other\nmembers.\n\n.. _oneof: \u003chttps://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields\u003e\n\n### [CreateCustomConstraintRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.CreateCustomConstraintRequest)\n\nThe request sent to the \\[CreateCustomConstraintRequest\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.CreateCustomConstraint\\] method.\n\n### [CreatePolicyRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.CreatePolicyRequest)\n\nThe request sent to the \\[CreatePolicyRequest\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy\\] method.\n\n### [CustomConstraint](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.CustomConstraint)\n\nA custom constraint defined by customers which can *only* be applied\nto the given resource types and organization.\n\nBy creating a custom constraint, customers can apply policies of\nthis custom constraint. *Creating a custom constraint itself does\nNOT apply any policy enforcement*.\n\n### [DeleteCustomConstraintRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.DeleteCustomConstraintRequest)\n\nThe request sent to the \\[DeleteCustomConstraint\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.DeleteCustomConstraint\\] method.\n\n### [DeletePolicyRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.DeletePolicyRequest)\n\nThe request sent to the \\[DeletePolicy\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy\\] method.\n\n### [GetCustomConstraintRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.GetCustomConstraintRequest)\n\nThe request sent to the \\[GetCustomConstraint\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.GetCustomConstraint\\] method.\n\n### [GetEffectivePolicyRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.GetEffectivePolicyRequest)\n\nThe request sent to the \\[GetEffectivePolicy\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy\\] method.\n\n### [GetPolicyRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.GetPolicyRequest)\n\nThe request sent to the \\[GetPolicy\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy\\] method.\n\n### [ListConstraintsRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListConstraintsRequest)\n\nThe request sent to the \\[ListConstraints\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints\\] method.\n\n### [ListConstraintsResponse](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListConstraintsResponse)\n\nThe response returned from the \\[ListConstraints\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints\\] method.\n\n### [ListCustomConstraintsRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListCustomConstraintsRequest)\n\nThe request sent to the \\[ListCustomConstraints\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListCustomConstraints\\] method.\n\n### [ListCustomConstraintsResponse](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListCustomConstraintsResponse)\n\nThe response returned from the \\[ListCustomConstraints\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListCustomConstraints\\] method.\nIt will be empty if no custom or managed constraints are set on the\norganization resource.\n\n### [ListPoliciesRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListPoliciesRequest)\n\nThe request sent to the \\[ListPolicies\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies\\] method.\n\n### [ListPoliciesResponse](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.ListPoliciesResponse)\n\nThe response returned from the \\[ListPolicies\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies\\] method. It will\nbe empty if no policies are set on the resource.\n\n### [Policy](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.Policy)\n\nDefines an organization policy which is used to specify\nconstraints for configurations of Google Cloud resources.\n\n### [PolicySpec](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.PolicySpec)\n\nDefines a Google Cloud policy specification which is used to\nspecify constraints for configurations of Google Cloud\nresources.\n\n### [UpdateCustomConstraintRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.UpdateCustomConstraintRequest)\n\nThe request sent to the \\[UpdateCustomConstraintRequest\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.UpdateCustomConstraint\\] method.\n\n### [UpdatePolicyRequest](/python/docs/reference/orgpolicy/latest/google.cloud.orgpolicy_v2.types.UpdatePolicyRequest)\n\nThe request sent to the \\[UpdatePolicyRequest\\]\n\\[google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy\\] method."]]