# Organization Policy v2 API - Class CustomConstraint (2.9.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.9.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.8.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.7.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.7.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.6.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.5.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.4.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.3.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.2.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.1.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.0.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [1.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.2.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [1.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.1.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)
- [1.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.0.0/Google.Cloud.OrgPolicy.V2.CustomConstraint)

    public sealed class CustomConstraint : IMessage<CustomConstraint>, IEquatable<CustomConstraint>, IDeepCloneable<CustomConstraint>, IBufferMessage, IMessage

Reference documentation and code samples for the Organization Policy v2 API 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*.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> CustomConstraint

## Implements

[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[CustomConstraint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[CustomConstraint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[CustomConstraint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.OrgPolicy.V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2)

## Assembly

Google.Cloud.OrgPolicy.V2.dll

## Constructors

### CustomConstraint()

    public CustomConstraint()

### CustomConstraint(CustomConstraint)

    public CustomConstraint(CustomConstraint other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint` |

## Properties

### ActionType

    public CustomConstraint.Types.ActionType ActionType { get; set; }

Allow or deny type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstrainthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint.Typeshttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint.Types.ActionType` |   |

### Condition

    public string Condition { get; set; }

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.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### CustomConstraintName

    public CustomConstraintName CustomConstraintName { get; set; }

[CustomConstraintName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraintName)-typed view over the [Name](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint#Google_Cloud_OrgPolicy_V2_CustomConstraint_Name) resource name property.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraintName` |   |

### Description

    public string Description { get; set; }

Detailed information about this custom policy constraint.
The max length of the description is 2000 characters.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DisplayName

    public string DisplayName { get; set; }

One line display name for the UI.
The max length of the display_name is 200 characters.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### MethodTypes

    public RepeatedField<CustomConstraint.Types.MethodType> MethodTypes { get; }

All the operations being applied for this constraint.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstrainthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint.Typeshttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint.Types.MethodType` |   |

### Name

    public string Name { get; set; }

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.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### ResourceTypes

    public RepeatedField<string> ResourceTypes { get; }

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

- `compute.googleapis.com/Instance`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://learn.microsoft.com/dotnet/api/system.string` |   |

### UpdateTime

    public Timestamp UpdateTime { get; set; }

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

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` |   |