Reference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::OrgPolicy::V2::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, see
Policy.
Constraints have a default behavior determined by the constraint_default
field, which is the enforcement behavior that is used in the absence of a
policy being defined or inherited for the resource in question.
Note: The following fields are mutually exclusive: boolean_constraint, list_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
Note: The following fields are mutually exclusive: boolean_constraint, list_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
Note: The following fields are mutually exclusive: boolean_constraint, list_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
(::String) — Detailed description of what this constraint controls as well as how and
where it is enforced.
Mutable.
#description=
defdescription=(value)->::String
Parameter
value (::String) — Detailed description of what this constraint controls as well as how and
where it is enforced.
Mutable.
Returns
(::String) — Detailed description of what this constraint controls as well as how and
where it is enforced.
Mutable.
#display_name
defdisplay_name()->::String
Returns
(::String) — The human readable name.
Mutable.
#display_name=
defdisplay_name=(value)->::String
Parameter
value (::String) — The human readable name.
Mutable.
Returns
(::String) — The human readable name.
Mutable.
#equivalent_constraint
defequivalent_constraint()->::String
Returns
(::String) — Managed constraint and canned constraint sometimes can have
equivalents. This field is used to store the equivalent constraint name.
#equivalent_constraint=
defequivalent_constraint=(value)->::String
Parameter
value (::String) — Managed constraint and canned constraint sometimes can have
equivalents. This field is used to store the equivalent constraint name.
Returns
(::String) — Managed constraint and canned constraint sometimes can have
equivalents. This field is used to store the equivalent constraint name.
Note: The following fields are mutually exclusive: list_constraint, boolean_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
Note: The following fields are mutually exclusive: list_constraint, boolean_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
Note: The following fields are mutually exclusive: list_constraint, boolean_constraint. If a field in that set is populated, all other fields in the set will automatically be cleared.
#name
defname()->::String
Returns
(::String) — Immutable. The resource name of the constraint. Must be in one of
the following forms:
[[["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-03 UTC."],[],[],null,["# Policy Simulator V1 API - Class Google::Cloud::OrgPolicy::V2::Constraint (v1.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.4.0 (latest)](/ruby/docs/reference/google-cloud-policy_simulator-v1/latest/Google-Cloud-OrgPolicy-V2-Constraint)\n- [1.3.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.3.0/Google-Cloud-OrgPolicy-V2-Constraint)\n- [1.2.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.2.1/Google-Cloud-OrgPolicy-V2-Constraint)\n- [1.1.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.1.0/Google-Cloud-OrgPolicy-V2-Constraint)\n- [1.0.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.0.1/Google-Cloud-OrgPolicy-V2-Constraint)\n- [0.4.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.4.0/Google-Cloud-OrgPolicy-V2-Constraint)\n- [0.3.2](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.3.2/Google-Cloud-OrgPolicy-V2-Constraint)\n- [0.2.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.2.0/Google-Cloud-OrgPolicy-V2-Constraint)\n- [0.1.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.1.1/Google-Cloud-OrgPolicy-V2-Constraint) \nReference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::OrgPolicy::V2::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.\nFor details about the inheritance rules, see\n[`Policy`](/ruby/docs/reference/google-cloud-policy_simulator-v1/latest/Google-Cloud-OrgPolicy-V2-Policy \"Google::Cloud::OrgPolicy::V2::Policy (class)\").\n\n\n\u003cbr /\u003e\n\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\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #boolean_constraint\n\n def boolean_constraint() -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::BooleanConstraint\n\n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::BooleanConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-BooleanConstraint)) --- Defines this constraint as being a boolean constraint.\n\n\n Note: The following fields are mutually exclusive: `boolean_constraint`, `list_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared.\n\n### #boolean_constraint=\n\n def boolean_constraint=(value) -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::BooleanConstraint\n\n**Parameter**\n\n- **value** ([::Google::Cloud::OrgPolicy::V2::Constraint::BooleanConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-BooleanConstraint)) --- Defines this constraint as being a boolean constraint.\n\n\nNote: The following fields are mutually exclusive: `boolean_constraint`, `list_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared. \n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::BooleanConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-BooleanConstraint)) --- Defines this constraint as being a boolean constraint.\n\n\n Note: The following fields are mutually exclusive: `boolean_constraint`, `list_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared.\n\n### #constraint_default\n\n def constraint_default() -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::ConstraintDefault\n\n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::ConstraintDefault](./Google-Cloud-OrgPolicy-V2-Constraint-ConstraintDefault)) --- The evaluation behavior of this constraint in the absence of a policy.\n\n### #constraint_default=\n\n def constraint_default=(value) -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::ConstraintDefault\n\n**Parameter**\n\n- **value** ([::Google::Cloud::OrgPolicy::V2::Constraint::ConstraintDefault](./Google-Cloud-OrgPolicy-V2-Constraint-ConstraintDefault)) --- The evaluation behavior of this constraint in the absence of a policy. \n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::ConstraintDefault](./Google-Cloud-OrgPolicy-V2-Constraint-ConstraintDefault)) --- The evaluation behavior of this constraint in the absence of a policy.\n\n### #description\n\n def description() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Detailed description of what this constraint controls as well as how and where it is enforced.\n\n Mutable.\n\n### #description=\n\n def description=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- Detailed description of what this constraint controls as well as how and where it is enforced.\n\n\nMutable. \n**Returns**\n\n- (::String) --- Detailed description of what this constraint controls as well as how and where it is enforced.\n\n Mutable.\n\n### #display_name\n\n def display_name() -\u003e ::String\n\n**Returns**\n\n- (::String) --- The human readable name.\n\n Mutable.\n\n### #display_name=\n\n def display_name=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- The human readable name.\n\n\nMutable. \n**Returns**\n\n- (::String) --- The human readable name.\n\n Mutable.\n\n### #equivalent_constraint\n\n def equivalent_constraint() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Managed constraint and canned constraint sometimes can have equivalents. This field is used to store the equivalent constraint name.\n\n### #equivalent_constraint=\n\n def equivalent_constraint=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- Managed constraint and canned constraint sometimes can have equivalents. This field is used to store the equivalent constraint name. \n**Returns**\n\n- (::String) --- Managed constraint and canned constraint sometimes can have equivalents. This field is used to store the equivalent constraint name.\n\n### #list_constraint\n\n def list_constraint() -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::ListConstraint\n\n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::ListConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-ListConstraint)) --- Defines this constraint as being a list constraint.\n\n\n Note: The following fields are mutually exclusive: `list_constraint`, `boolean_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared.\n\n### #list_constraint=\n\n def list_constraint=(value) -\u003e ::Google::Cloud::OrgPolicy::V2::Constraint::ListConstraint\n\n**Parameter**\n\n- **value** ([::Google::Cloud::OrgPolicy::V2::Constraint::ListConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-ListConstraint)) --- Defines this constraint as being a list constraint.\n\n\nNote: The following fields are mutually exclusive: `list_constraint`, `boolean_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared. \n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::Constraint::ListConstraint](./Google-Cloud-OrgPolicy-V2-Constraint-ListConstraint)) --- Defines this constraint as being a list constraint.\n\n\n Note: The following fields are mutually exclusive: `list_constraint`, `boolean_constraint`. If a field in that set is populated, all other fields in the set will automatically be cleared.\n\n### #name\n\n def name() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Immutable. The resource name of the constraint. Must be in one of the following forms:\n\n - `projects/{project_number}/constraints/{constraint_name}`\n - `folders/{folder_id}/constraints/{constraint_name}`\n - `organizations/{organization_id}/constraints/{constraint_name}`\n\n For example, \"/projects/123/constraints/compute.disableSerialPortAccess\".\n\n### #name=\n\n def name=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- Immutable. The resource name of the constraint. Must be in one of the following forms:\n\n\n - `projects/{project_number}/constraints/{constraint_name}`\n - `folders/{folder_id}/constraints/{constraint_name}`\n - `organizations/{organization_id}/constraints/{constraint_name}`\n\nFor example, \"/projects/123/constraints/compute.disableSerialPortAccess\". \n**Returns**\n\n- (::String) --- Immutable. The resource name of the constraint. Must be in one of the following forms:\n\n - `projects/{project_number}/constraints/{constraint_name}`\n - `folders/{folder_id}/constraints/{constraint_name}`\n - `organizations/{organization_id}/constraints/{constraint_name}`\n\n For example, \"/projects/123/constraints/compute.disableSerialPortAccess\".\n\n### #supports_dry_run\n\n def supports_dry_run() -\u003e ::Boolean\n\n**Returns**\n\n- (::Boolean) --- Shows if dry run is supported for this constraint or not.\n\n### #supports_dry_run=\n\n def supports_dry_run=(value) -\u003e ::Boolean\n\n**Parameter**\n\n- **value** (::Boolean) --- Shows if dry run is supported for this constraint or not. \n**Returns**\n\n- (::Boolean) --- Shows if dry run is supported for this constraint or not.\n\n### #supports_simulation\n\n def supports_simulation() -\u003e ::Boolean\n\n**Returns**\n\n- (::Boolean) --- Shows if simulation is supported for this constraint or not.\n\n### #supports_simulation=\n\n def supports_simulation=(value) -\u003e ::Boolean\n\n**Parameter**\n\n- **value** (::Boolean) --- Shows if simulation is supported for this constraint or not. \n**Returns**\n\n- (::Boolean) --- Shows if simulation is supported for this constraint or not."]]