# Organization Policy v2 API - Class OrgPolicy.OrgPolicyBase (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.OrgPolicy.OrgPolicyBase)
- [2.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.8.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.7.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.7.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.6.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.5.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.4.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.3.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.2.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.1.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/2.0.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [1.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.2.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [1.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.1.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)
- [1.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/1.0.0/Google.Cloud.OrgPolicy.V2.OrgPolicy.OrgPolicyBase)

    [BindServiceMethod(typeof(OrgPolicy), "BindService")]
    public abstract class OrgPolicy.OrgPolicyBase

Reference documentation and code samples for the Organization Policy v2 API class OrgPolicy.OrgPolicyBase.

Base class for server-side implementations of OrgPolicy

## Inheritance

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

## 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.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [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

## Methods

### CreateCustomConstraint(CreateCustomConstraintRequest, ServerCallContext)

    public virtual Task<CustomConstraint> CreateCustomConstraint(CreateCustomConstraintRequest request, ServerCallContext context)

Creates a custom constraint.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
organization does not exist.
Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
constraint already exists on the given organization.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CreateCustomConstraintRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint` | The response to send back to the client (wrapped by a task). |

### CreatePolicy(CreatePolicyRequest, ServerCallContext)

    public virtual Task<Policy> CreatePolicy(CreatePolicyRequest request, ServerCallContext context)

Creates a policy.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
constraint does not exist.
Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
policy already exists on the given Google Cloud resource.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CreatePolicyRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.Policy` | The response to send back to the client (wrapped by a task). |

### DeleteCustomConstraint(DeleteCustomConstraintRequest, ServerCallContext)

    public virtual Task<Empty> DeleteCustomConstraint(DeleteCustomConstraintRequest request, ServerCallContext context)

Deletes a custom constraint.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
constraint does not exist.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.DeleteCustomConstraintRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Empty.html` | The response to send back to the client (wrapped by a task). |

### DeletePolicy(DeletePolicyRequest, ServerCallContext)

    public virtual Task<Empty> DeletePolicy(DeletePolicyRequest request, ServerCallContext context)

Deletes a policy.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
constraint or organization policy does not exist.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.DeletePolicyRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Empty.html` | The response to send back to the client (wrapped by a task). |

### GetCustomConstraint(GetCustomConstraintRequest, ServerCallContext)

    public virtual Task<CustomConstraint> GetCustomConstraint(GetCustomConstraintRequest request, ServerCallContext context)

Gets a custom or managed constraint.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
custom or managed constraint does not exist.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.GetCustomConstraintRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint` | The response to send back to the client (wrapped by a task). |

### GetEffectivePolicy(GetEffectivePolicyRequest, ServerCallContext)

    public virtual Task<Policy> GetEffectivePolicy(GetEffectivePolicyRequest request, ServerCallContext context)

Gets the effective policy on a resource. This is the result of merging
policies in the resource hierarchy and evaluating conditions. The
returned policy will not have an `etag` or `condition` set because it is
an evaluated policy across multiple resources.
Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
not be expanded.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.GetEffectivePolicyRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.Policy` | The response to send back to the client (wrapped by a task). |

### GetPolicy(GetPolicyRequest, ServerCallContext)

    public virtual Task<Policy> GetPolicy(GetPolicyRequest request, ServerCallContext context)

Gets a policy on a resource.

If no policy is set on the resource, `NOT_FOUND` is returned. The
`etag` value can be used with `UpdatePolicy()` to update a
policy during read-modify-write.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.GetPolicyRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.Policy` | The response to send back to the client (wrapped by a task). |

### ListConstraints(ListConstraintsRequest, ServerCallContext)

    public virtual Task<ListConstraintsResponse> ListConstraints(ListConstraintsRequest request, ServerCallContext context)

Lists constraints that could be applied on the specified resource.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListConstraintsRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListConstraintsResponse` | The response to send back to the client (wrapped by a task). |

### ListCustomConstraints(ListCustomConstraintsRequest, ServerCallContext)

    public virtual Task<ListCustomConstraintsResponse> ListCustomConstraints(ListCustomConstraintsRequest request, ServerCallContext context)

Retrieves all of the custom constraints that exist on a particular
organization resource.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListCustomConstraintsRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListCustomConstraintsResponse` | The response to send back to the client (wrapped by a task). |

### ListPolicies(ListPoliciesRequest, ServerCallContext)

    public virtual Task<ListPoliciesResponse> ListPolicies(ListPoliciesRequest request, ServerCallContext context)

Retrieves all of the policies that exist on a particular resource.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListPoliciesRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.ListPoliciesResponse` | The response to send back to the client (wrapped by a task). |

### UpdateCustomConstraint(UpdateCustomConstraintRequest, ServerCallContext)

    public virtual Task<CustomConstraint> UpdateCustomConstraint(UpdateCustomConstraintRequest request, ServerCallContext context)

Updates a custom constraint.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
constraint does not exist.

Note: the supplied policy will perform a full overwrite of all
fields.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.UpdateCustomConstraintRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.CustomConstraint` | The response to send back to the client (wrapped by a task). |

### UpdatePolicy(UpdatePolicyRequest, ServerCallContext)

    public virtual Task<Policy> UpdatePolicy(UpdatePolicyRequest request, ServerCallContext context)

Updates a policy.

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
constraint or the policy do not exist.
Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
supplied in the request does not match the persisted etag of the policy

Note: the supplied policy will perform a full overwrite of all
fields.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.UpdatePolicyRequest` The request received from the client. |
| `context` | `https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.ServerCallContext.html` The context of the server-side call handler being invoked. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.OrgPolicy.V2/latest/Google.Cloud.OrgPolicy.V2.Policy` | The response to send back to the client (wrapped by a task). |