# Google Cloud Org Policy V2 Client - Class CustomConstraint (1.3.3)

1.3.3 (latest) 1.3.2 1.2.2 1.1.3 1.0.0 0.7.0 0.6.5 0.5.3 0.4.2 0.3.7 Reference documentation and code samples for the Google Cloud Org Policy V2 Client class 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*.

Generated from protobuf message `google.cloud.orgpolicy.v2.CustomConstraint`

## Namespace

Google \\ Cloud \\ OrgPolicy \\ V2

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Immutable. Name of the constraint. This is unique within the organization. Format of the name should be \* \* `organizations/{organization_id}/customConstraints/{custom_constraint_id}` Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms` 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` | `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`. |
| `↳ method_types` | `int[]` All the operations being applied for this constraint. |
| `↳ condition` | `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. |
| `↳ action_type` | `int` Allow or deny type. |
| `↳ display_name` | `string` One line display name for the UI. The max length of the display_name is 200 characters. |
| `↳ description` | `string` Detailed information about this custom policy constraint. The max length of the description is 2000 characters. |
| `↳ update_time` | `https://protobuf.dev/reference/php/api-docs/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. |

### getName

Immutable. Name of the constraint. This is unique within the organization.

Format of the name should be

- `organizations/{organization_id}/customConstraints/{custom_constraint_id}` Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms` The max length is 70 characters and the minimum length is 1. Note that the prefix `organizations/{organization_id}/customConstraints/` is not counted.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Immutable. Name of the constraint. This is unique within the organization.

Format of the name should be

- `organizations/{organization_id}/customConstraints/{custom_constraint_id}` Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms` The max length is 70 characters and the minimum length is 1. Note that the prefix `organizations/{organization_id}/customConstraints/` is not counted.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getResourceTypes

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** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<string>` |   |

### setResourceTypes

Immutable. The resource instance type on which this policy applies. Format
will be of the form : `<service name>/<type>` Example:

- `compute.googleapis.com/Instance`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMethodTypes

All the operations being applied for this constraint.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<int>` |   |

### setMethodTypes

All the operations being applied for this constraint.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCondition

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** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setCondition

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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getActionType

Allow or deny type.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [ActionType](https://docs.cloud.google.com/php/docs/reference/cloud-org-policy/latest/V2.CustomConstraint.ActionType). |

### setActionType

Allow or deny type.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [ActionType](https://docs.cloud.google.com/php/docs/reference/cloud-org-policy/latest/V2.CustomConstraint.ActionType). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDisplayName

One line display name for the UI.

The max length of the display_name is 200 characters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDisplayName

One line display name for the UI.

The max length of the display_name is 200 characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDescription

Detailed information about this custom policy constraint.

The max length of the description is 2000 characters.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDescription

Detailed information about this custom policy constraint.

The max length of the description is 2000 characters.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getUpdateTime

Output only. The last time this custom constraint was updated. This
represents the last time that the `CreateCustomConstraint` or
`UpdateCustomConstraint` methods were called.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp|null` |   |

### hasUpdateTime

### clearUpdateTime

### setUpdateTime

Output only. The last time this custom constraint was updated. This
represents the last time that the `CreateCustomConstraint` or
`UpdateCustomConstraint` methods were called.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Timestamp` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |