Reference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::OrgPolicy::V2::CustomConstraint.
A custom constraint defined by customers which can only be 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.
(::String) — A Common Expression Language (CEL) condition which is used in the
evaluation of the constraint. For example:
resource.instanceName.matches("[production|test]_.*_(\d)+") or,
resource.management.auto_upgrade == true
The max length of the condition is 1000 characters.
#condition=
defcondition=(value)->::String
Parameter
value (::String) — A Common Expression Language (CEL) condition which is used in the
evaluation of the constraint. For example:
resource.instanceName.matches("[production|test]_.*_(\d)+") or,
resource.management.auto_upgrade == true
The max length of the condition is 1000 characters.
Returns
(::String) — A Common Expression Language (CEL) condition which is used in the
evaluation of the constraint. For example:
resource.instanceName.matches("[production|test]_.*_(\d)+") or,
resource.management.auto_upgrade == true
The max length of the condition is 1000 characters.
#description
defdescription()->::String
Returns
(::String) — Detailed information about this custom policy constraint.
The max length of the description is 2000 characters.
#description=
defdescription=(value)->::String
Parameter
value (::String) — Detailed information about this custom policy constraint.
The max length of the description is 2000 characters.
Returns
(::String) — Detailed information about this custom policy constraint.
The max length of the description is 2000 characters.
#display_name
defdisplay_name()->::String
Returns
(::String) — One line display name for the UI.
The max length of the display_name is 200 characters.
#display_name=
defdisplay_name=(value)->::String
Parameter
value (::String) — One line display name for the UI.
The max length of the display_name is 200 characters.
Returns
(::String) — One line display name for the UI.
The max length of the display_name is 200 characters.
The max length is 70 characters and the minimum length is 1. Note that the
prefix organizations/{organization_id}/customConstraints/ is not counted.
#resource_types
defresource_types()->::Array<::String>
Returns
(::Array<::String>) —
Immutable. The resource instance type on which this policy applies. Format
will be of the form : <service name>/<type> Example:
compute.googleapis.com/Instance.
#resource_types=
defresource_types=(value)->::Array<::String>
Parameter
value (::Array<::String>) —
Immutable. The resource instance type on which this policy applies. Format
will be of the form : <service name>/<type> Example:
compute.googleapis.com/Instance.
Returns
(::Array<::String>) —
Immutable. The resource instance type on which this policy applies. Format
will be of the form : <service name>/<type> Example:
compute.googleapis.com/Instance.
#update_time
defupdate_time()->::Google::Protobuf::Timestamp
Returns
(::Google::Protobuf::Timestamp) — Output only. The last time this custom constraint was updated. This
represents the last time that the CreateCustomConstraint or
UpdateCustomConstraint methods were called.
[[["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::CustomConstraint (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-CustomConstraint)\n- [1.3.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.3.0/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [1.2.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.2.1/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [1.1.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.1.0/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [1.0.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.0.1/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [0.4.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.4.0/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [0.3.2](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.3.2/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [0.2.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.2.0/Google-Cloud-OrgPolicy-V2-CustomConstraint)\n- [0.1.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.1.1/Google-Cloud-OrgPolicy-V2-CustomConstraint) \nReference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::OrgPolicy::V2::CustomConstraint.\n\nA custom constraint defined by customers which can *only* be applied to the\ngiven resource types and organization.\n\n\n\u003cbr /\u003e\n\nBy creating a custom constraint, customers can apply policies of this\ncustom constraint. *Creating a custom constraint itself does NOT apply any\npolicy enforcement*. \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### #action_type\n\n def action_type() -\u003e ::Google::Cloud::OrgPolicy::V2::CustomConstraint::ActionType\n\n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::CustomConstraint::ActionType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-ActionType)) --- Allow or deny type.\n\n### #action_type=\n\n def action_type=(value) -\u003e ::Google::Cloud::OrgPolicy::V2::CustomConstraint::ActionType\n\n**Parameter**\n\n- **value** ([::Google::Cloud::OrgPolicy::V2::CustomConstraint::ActionType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-ActionType)) --- Allow or deny type. \n**Returns**\n\n- ([::Google::Cloud::OrgPolicy::V2::CustomConstraint::ActionType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-ActionType)) --- Allow or deny type.\n\n### #condition\n\n def condition() -\u003e ::String\n\n**Returns**\n\n- (::String) --- A Common Expression Language (CEL) condition which is used in the evaluation of the constraint. For example: `resource.instanceName.matches(\"[production|test]_.*_(\\d)+\")` or, `resource.management.auto_upgrade == true`\n\n\n The max length of the condition is 1000 characters.\n\n### #condition=\n\n def condition=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- A Common Expression Language (CEL) condition which is used in the evaluation of the constraint. For example: `resource.instanceName.matches(\"[production|test]_.*_(\\d)+\")` or, `resource.management.auto_upgrade == true`\n\n\nThe max length of the condition is 1000 characters. \n**Returns**\n\n- (::String) --- A Common Expression Language (CEL) condition which is used in the evaluation of the constraint. For example: `resource.instanceName.matches(\"[production|test]_.*_(\\d)+\")` or, `resource.management.auto_upgrade == true`\n\n\n The max length of the condition is 1000 characters.\n\n### #description\n\n def description() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Detailed information about this custom policy constraint. The max length of the description is 2000 characters.\n\n### #description=\n\n def description=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- Detailed information about this custom policy constraint. The max length of the description is 2000 characters. \n**Returns**\n\n- (::String) --- Detailed information about this custom policy constraint. The max length of the description is 2000 characters.\n\n### #display_name\n\n def display_name() -\u003e ::String\n\n**Returns**\n\n- (::String) --- One line display name for the UI. The max length of the display_name is 200 characters.\n\n### #display_name=\n\n def display_name=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- One line display name for the UI. The max length of the display_name is 200 characters. \n**Returns**\n\n- (::String) --- One line display name for the UI. The max length of the display_name is 200 characters.\n\n### #method_types\n\n def method_types() -\u003e ::Array\u003c::Google::Cloud::OrgPolicy::V2::CustomConstraint::MethodType\u003e\n\n**Returns**\n\n- (::Array\\\u003c[::Google::Cloud::OrgPolicy::V2::CustomConstraint::MethodType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-MethodType)\\\u003e) --- All the operations being applied for this constraint.\n\n### #method_types=\n\n def method_types=(value) -\u003e ::Array\u003c::Google::Cloud::OrgPolicy::V2::CustomConstraint::MethodType\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c[::Google::Cloud::OrgPolicy::V2::CustomConstraint::MethodType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-MethodType)\\\u003e) --- All the operations being applied for this constraint. \n**Returns**\n\n- (::Array\\\u003c[::Google::Cloud::OrgPolicy::V2::CustomConstraint::MethodType](./Google-Cloud-OrgPolicy-V2-CustomConstraint-MethodType)\\\u003e) --- All the operations being applied for this constraint.\n\n### #name\n\n def name() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Immutable. Name of the constraint. This is unique within the organization. Format of the name should be\n\n - `organizations/{organization_id}/customConstraints/{custom_constraint_id}`\n\n Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`\n\n The max length is 70 characters and the minimum length is 1. Note that the\n prefix `organizations/{organization_id}/customConstraints/` is not counted.\n\n### #name=\n\n def name=(value) -\u003e ::String\n\n**Parameter**\n\n- **value** (::String) --- Immutable. Name of the constraint. This is unique within the organization. Format of the name should be\n\n\n - `organizations/{organization_id}/customConstraints/{custom_constraint_id}`\n\n Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`\n\n The max length is 70 characters and the minimum length is 1. Note that the\nprefix `organizations/{organization_id}/customConstraints/` is not counted. \n**Returns**\n\n- (::String) --- Immutable. Name of the constraint. This is unique within the organization. Format of the name should be\n\n - `organizations/{organization_id}/customConstraints/{custom_constraint_id}`\n\n Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`\n\n The max length is 70 characters and the minimum length is 1. Note that the\n prefix `organizations/{organization_id}/customConstraints/` is not counted.\n\n### #resource_types\n\n def resource_types() -\u003e ::Array\u003c::String\u003e\n\n**Returns**\n\n- (::Array\\\u003c::String\\\u003e) --- Immutable. The resource instance type on which this policy applies. Format\n will be of the form : `\u003cservice name\u003e/\u003ctype\u003e` Example:\n\n - `compute.googleapis.com/Instance`.\n\n### #resource_types=\n\n def resource_types=(value) -\u003e ::Array\u003c::String\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c::String\\\u003e) ---\n\n Immutable. The resource instance type on which this policy applies. Format\n will be of the form : `\u003cservice name\u003e/\u003ctype\u003e` Example:\n- `compute.googleapis.com/Instance`. \n**Returns**\n\n- (::Array\\\u003c::String\\\u003e) --- Immutable. The resource instance type on which this policy applies. Format\n will be of the form : `\u003cservice name\u003e/\u003ctype\u003e` Example:\n\n - `compute.googleapis.com/Instance`.\n\n### #update_time\n\n def update_time() -\u003e ::Google::Protobuf::Timestamp\n\n**Returns**\n\n- ([::Google::Protobuf::Timestamp](./Google-Protobuf-Timestamp)) --- Output only. The last time this custom constraint was updated. This represents the last time that the `CreateCustomConstraint` or `UpdateCustomConstraint` methods were called."]]