# Class OrgPolicyClient (2.93.0)

2.93.0 (latest) 2.91.0 2.88.0 2.87.0 2.85.0 2.83.0 2.82.0 2.80.0 2.78.0 2.76.0 2.75.0 2.74.0 2.73.0 2.72.0 2.70.0 2.68.0 2.67.0 2.64.0 2.63.0 2.62.0 2.60.0 2.59.0 2.58.0 2.57.0 2.56.0 2.55.0 2.54.0 2.53.0 2.52.0 2.51.0 2.49.0 2.48.0 2.47.0 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.0 2.14.0 2.13.0 2.12.0 2.11.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.7-SNAPSHOT 2.2.1 2.1.2 2.0.10

|---|---|
| [GitHub Repository](https://github.com/googleapis/google-cloud-java/tree/main/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyClient.java) | [Product Reference](https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/n/a) |

Service Description: An interface for managing organization policies.

The Organization Policy Service provides a simple mechanism for organizations to restrict the
allowed configurations across their entire resource hierarchy.

You can use a policy to configure restrictions on resources. For example, you can enforce a
policy that restricts which Google Cloud APIs can be activated in a certain part of your resource
hierarchy, or prevents serial port access to VM instances in a particular folder.

Policies are inherited down through the resource hierarchy. A policy applied to a parent
resource automatically applies to all its child resources unless overridden with a policy lower
in the hierarchy.

A constraint defines an aspect of a resource's configuration that can be controlled by an
organization's policy administrator. Policies are a collection of constraints that defines their
allowable configuration on a particular resource and its child resources.

This class provides the ability to make remote calls to the backing service through method
calls that map to API methods. Sample code to get started:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
       Policy response = orgPolicyClient.getPolicy(name);
     }
     
Note: close() needs to be called on the OrgPolicyClient object to clean up resources such as
threads. In the example above, try-with-resources is used, which automatically calls close().

| Method | Description | Method Variants |
|---|---|---|
| ListConstraints | Lists constraints that could be applied on the specified resource. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listConstraints(ListConstraintsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listConstraints(FolderName parent) - listConstraints(OrganizationName parent) - listConstraints(ProjectName parent) - listConstraints(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listConstraintsPagedCallable() - listConstraintsCallable() |
| ListPolicies | Retrieves all of the policies that exist on a particular resource. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listPolicies(ListPoliciesRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listPolicies(FolderName parent) - listPolicies(OrganizationName parent) - listPolicies(ProjectName parent) - listPolicies(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listPoliciesPagedCallable() - listPoliciesCallable() |
| GetPolicy | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getPolicy(GetPolicyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getPolicy(PolicyName name) - getPolicy(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getPolicyCallable() |
| GetEffectivePolicy | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getEffectivePolicy(GetEffectivePolicyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getEffectivePolicy(PolicyName name) - getEffectivePolicy(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getEffectivePolicyCallable() |
| CreatePolicy | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createPolicy(CreatePolicyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createPolicy(FolderName parent, Policy policy) - createPolicy(OrganizationName parent, Policy policy) - createPolicy(ProjectName parent, Policy policy) - createPolicy(String parent, Policy policy) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createPolicyCallable() |
| UpdatePolicy | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updatePolicy(UpdatePolicyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updatePolicy(Policy policy) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updatePolicyCallable() |
| DeletePolicy | Deletes a policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or organization policy does not exist. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - deletePolicy(DeletePolicyRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - deletePolicy(PolicyName name) - deletePolicy(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - deletePolicyCallable() |
| CreateCustomConstraint | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - createCustomConstraint(CreateCustomConstraintRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - createCustomConstraint(OrganizationName parent, CustomConstraint customConstraint) - createCustomConstraint(String parent, CustomConstraint customConstraint) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - createCustomConstraintCallable() |
| UpdateCustomConstraint | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - updateCustomConstraint(UpdateCustomConstraintRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - updateCustomConstraint(CustomConstraint customConstraint) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - updateCustomConstraintCallable() |
| GetCustomConstraint | 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. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - getCustomConstraint(GetCustomConstraintRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - getCustomConstraint(CustomConstraintName name) - getCustomConstraint(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - getCustomConstraintCallable() |
| ListCustomConstraints | Retrieves all of the custom constraints that exist on a particular organization resource. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - listCustomConstraints(ListCustomConstraintsRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - listCustomConstraints(OrganizationName parent) - listCustomConstraints(String parent) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - listCustomConstraintsPagedCallable() - listCustomConstraintsCallable() |
| DeleteCustomConstraint | Deletes a custom constraint. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. | Request object method variants only take one parameter, a request object, which must be constructed before the call. - deleteCustomConstraint(DeleteCustomConstraintRequest request) "Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method. - deleteCustomConstraint(CustomConstraintName name) - deleteCustomConstraint(String name) Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service. - deleteCustomConstraintCallable() |
[Methods]

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with
these names, this class includes a format method for each type of name, and additionally a parse
method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of OrgPolicySettings to create().
For example:

To customize credentials:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     OrgPolicySettings orgPolicySettings =
         OrgPolicySettings.newBuilder()
             .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
             .build();
     OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
     
To customize the endpoint:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     OrgPolicySettings orgPolicySettings =
         OrgPolicySettings.newBuilder().setEndpoint(myEndpoint).build();
     OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
     
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
the wire:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     OrgPolicySettings orgPolicySettings = OrgPolicySettings.newHttpJsonBuilder().build();
     OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
     
Please refer to the GitHub repository's samples for more quickstart code snippets.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> OrgPolicyClient

## Static Methods

### create()

    public static final OrgPolicyClient create()

Constructs an instance of OrgPolicyClient with default settings.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(OrgPolicySettings settings)

    public static final OrgPolicyClient create(OrgPolicySettings settings)

Constructs an instance of OrgPolicyClient, using the given settings. The channels are created
based on the settings passed in, or defaults for any settings that are not set.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicySettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### create(OrgPolicyStub stub)

    public static final OrgPolicyClient create(OrgPolicyStub stub)

Constructs an instance of OrgPolicyClient, using the given stub for making calls. This is for
advanced usage - prefer using create(OrgPolicySettings).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.stub.OrgPolicyStub` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient` |   |

## Constructors

### OrgPolicyClient(OrgPolicySettings settings)

    protected OrgPolicyClient(OrgPolicySettings settings)

Constructs an instance of OrgPolicyClient, using the given settings. This is protected so that
it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicySettings` |

### OrgPolicyClient(OrgPolicyStub stub)

    protected OrgPolicyClient(OrgPolicyStub stub)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stub` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.stub.OrgPolicyStub` |

## Methods

### awaitTermination(long duration, TimeUnit unit)

    public boolean awaitTermination(long duration, TimeUnit unit)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `unit` | `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeUnit.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### close()

    public final void close()

### createCustomConstraint(CreateCustomConstraintRequest request)

    public final CustomConstraint createCustomConstraint(CreateCustomConstraintRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CreateCustomConstraintRequest request =
           CreateCustomConstraintRequest.newBuilder()
               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
               .setCustomConstraint(CustomConstraint.newBuilder().build())
               .build();
       CustomConstraint response = orgPolicyClient.createCustomConstraint(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### createCustomConstraint(OrganizationName parent, CustomConstraint customConstraint)

    public final CustomConstraint createCustomConstraint(OrganizationName parent, CustomConstraint customConstraint)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
       CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
       CustomConstraint response = orgPolicyClient.createCustomConstraint(parent, customConstraint);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrganizationName` Required. Must be in the following form: - `organizations/{organization_id}` <br /> |
| `customConstraint` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` Required. Custom constraint to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### createCustomConstraint(String parent, CustomConstraint customConstraint)

    public final CustomConstraint createCustomConstraint(String parent, CustomConstraint customConstraint)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String parent = OrganizationName.of("[ORGANIZATION]").toString();
       CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
       CustomConstraint response = orgPolicyClient.createCustomConstraint(parent, customConstraint);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Must be in the following form: - `organizations/{organization_id}` <br /> |
| `customConstraint` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` Required. Custom constraint to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### createCustomConstraintCallable()

    public final UnaryCallable<CreateCustomConstraintRequest,CustomConstraint> createCustomConstraintCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CreateCustomConstraintRequest request =
           CreateCustomConstraintRequest.newBuilder()
               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
               .setCustomConstraint(CustomConstraint.newBuilder().build())
               .build();
       ApiFuture<CustomConstraint> future =
           orgPolicyClient.createCustomConstraintCallable().futureCall(request);
       // Do something.
       CustomConstraint response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint>` |   |

### createPolicy(CreatePolicyRequest request)

    public final Policy createPolicy(CreatePolicyRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CreatePolicyRequest request =
           CreatePolicyRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPolicy(Policy.newBuilder().build())
               .build();
       Policy response = orgPolicyClient.createPolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CreatePolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### createPolicy(FolderName parent, Policy policy)

    public final Policy createPolicy(FolderName parent, Policy policy)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       FolderName parent = FolderName.of("[FOLDER]");
       Policy policy = Policy.newBuilder().build();
       Policy response = orgPolicyClient.createPolicy(parent, policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.FolderName` Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |
| `policy` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` Required. Policy to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### createPolicy(OrganizationName parent, Policy policy)

    public final Policy createPolicy(OrganizationName parent, Policy policy)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
       Policy policy = Policy.newBuilder().build();
       Policy response = orgPolicyClient.createPolicy(parent, policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrganizationName` Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |
| `policy` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` Required. Policy to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### createPolicy(ProjectName parent, Policy policy)

    public final Policy createPolicy(ProjectName parent, Policy policy)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ProjectName parent = ProjectName.of("[PROJECT]");
       Policy policy = Policy.newBuilder().build();
       Policy response = orgPolicyClient.createPolicy(parent, policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ProjectName` Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |
| `policy` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` Required. Policy to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### createPolicy(String parent, Policy policy)

    public final Policy createPolicy(String parent, Policy policy)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String parent = ProjectName.of("[PROJECT]").toString();
       Policy policy = Policy.newBuilder().build();
       Policy response = orgPolicyClient.createPolicy(parent, policy);
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The Google Cloud resource that will parent the new policy. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |
| `policy` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` Required. Policy to create. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### createPolicyCallable()

    public final UnaryCallable<CreatePolicyRequest,Policy> createPolicyCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CreatePolicyRequest request =
           CreatePolicyRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPolicy(Policy.newBuilder().build())
               .build();
       ApiFuture<Policy> future = orgPolicyClient.createPolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CreatePolicyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy>` |   |

### deleteCustomConstraint(CustomConstraintName name)

    public final void deleteCustomConstraint(CustomConstraintName name)

Deletes a custom constraint.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
       orgPolicyClient.deleteCustomConstraint(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraintName` Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules. |

### deleteCustomConstraint(DeleteCustomConstraintRequest request)

    public final void deleteCustomConstraint(DeleteCustomConstraintRequest request)

Deletes a custom constraint.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       DeleteCustomConstraintRequest request =
           DeleteCustomConstraintRequest.newBuilder()
               .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
               .build();
       orgPolicyClient.deleteCustomConstraint(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest` The request object containing all of the parameters for the API call. |

### deleteCustomConstraint(String name)

    public final void deleteCustomConstraint(String name)

Deletes a custom constraint.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString();
       orgPolicyClient.deleteCustomConstraint(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Name of the custom constraint to delete. See the custom constraint entry for naming rules. |

### deleteCustomConstraintCallable()

    public final UnaryCallable<DeleteCustomConstraintRequest,Empty> deleteCustomConstraintCallable()

Deletes a custom constraint.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       DeleteCustomConstraintRequest request =
           DeleteCustomConstraintRequest.newBuilder()
               .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
               .build();
       ApiFuture<Empty> future =
           orgPolicyClient.deleteCustomConstraintCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html>` |   |

### deletePolicy(DeletePolicyRequest request)

    public final void deletePolicy(DeletePolicyRequest request)

Deletes a policy.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       DeletePolicyRequest request =
           DeletePolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .setEtag("etag3123477")
               .build();
       orgPolicyClient.deletePolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.DeletePolicyRequest` The request object containing all of the parameters for the API call. |

### deletePolicy(PolicyName name)

    public final void deletePolicy(PolicyName name)

Deletes a policy.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
       orgPolicyClient.deletePolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.PolicyName` Required. Name of the policy to delete. See the policy entry for naming rules. |

### deletePolicy(String name)

    public final void deletePolicy(String name)

Deletes a policy.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
       orgPolicyClient.deletePolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Name of the policy to delete. See the policy entry for naming rules. |

### deletePolicyCallable()

    public final UnaryCallable<DeletePolicyRequest,Empty> deletePolicyCallable()

Deletes a policy.

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       DeletePolicyRequest request =
           DeletePolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .setEtag("etag3123477")
               .build();
       ApiFuture<Empty> future = orgPolicyClient.deletePolicyCallable().futureCall(request);
       // Do something.
       future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.DeletePolicyRequest,https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html>` |   |

### getCustomConstraint(CustomConstraintName name)

    public final CustomConstraint getCustomConstraint(CustomConstraintName name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
       CustomConstraint response = orgPolicyClient.getCustomConstraint(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraintName` Required. Resource name of the custom or managed constraint. See the custom constraint entry for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### getCustomConstraint(GetCustomConstraintRequest request)

    public final CustomConstraint getCustomConstraint(GetCustomConstraintRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetCustomConstraintRequest request =
           GetCustomConstraintRequest.newBuilder()
               .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
               .build();
       CustomConstraint response = orgPolicyClient.getCustomConstraint(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### getCustomConstraint(String name)

    public final CustomConstraint getCustomConstraint(String name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString();
       CustomConstraint response = orgPolicyClient.getCustomConstraint(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Resource name of the custom or managed constraint. See the custom constraint entry for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### getCustomConstraintCallable()

    public final UnaryCallable<GetCustomConstraintRequest,CustomConstraint> getCustomConstraintCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetCustomConstraintRequest request =
           GetCustomConstraintRequest.newBuilder()
               .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
               .build();
       ApiFuture<CustomConstraint> future =
           orgPolicyClient.getCustomConstraintCallable().futureCall(request);
       // Do something.
       CustomConstraint response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint>` |   |

### getEffectivePolicy(GetEffectivePolicyRequest request)

    public final Policy getEffectivePolicy(GetEffectivePolicyRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetEffectivePolicyRequest request =
           GetEffectivePolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .build();
       Policy response = orgPolicyClient.getEffectivePolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getEffectivePolicy(PolicyName name)

    public final Policy getEffectivePolicy(PolicyName name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
       Policy response = orgPolicyClient.getEffectivePolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.PolicyName` Required. The effective policy to compute. See Policy for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getEffectivePolicy(String name)

    public final Policy getEffectivePolicy(String name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
       Policy response = orgPolicyClient.getEffectivePolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The effective policy to compute. See Policy for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getEffectivePolicyCallable()

    public final UnaryCallable<GetEffectivePolicyRequest,Policy> getEffectivePolicyCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetEffectivePolicyRequest request =
           GetEffectivePolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .build();
       ApiFuture<Policy> future = orgPolicyClient.getEffectivePolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy>` |   |

### getPolicy(GetPolicyRequest request)

    public final Policy getPolicy(GetPolicyRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetPolicyRequest request =
           GetPolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .build();
       Policy response = orgPolicyClient.getPolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetPolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getPolicy(PolicyName name)

    public final Policy getPolicy(PolicyName name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
       Policy response = orgPolicyClient.getPolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.PolicyName` Required. Resource name of the policy. See Policy for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getPolicy(String name)

    public final Policy getPolicy(String name)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
       Policy response = orgPolicyClient.getPolicy(name);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. Resource name of the policy. See Policy for naming requirements. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### getPolicyCallable()

    public final UnaryCallable<GetPolicyRequest,Policy> getPolicyCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       GetPolicyRequest request =
           GetPolicyRequest.newBuilder()
               .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
               .build();
       ApiFuture<Policy> future = orgPolicyClient.getPolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.GetPolicyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy>` |   |

### getSettings()

    public final OrgPolicySettings getSettings()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicySettings` |   |

### getStub()

    public OrgPolicyStub getStub()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.stub.OrgPolicyStub` |   |

### isShutdown()

    public boolean isShutdown()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isTerminated()

    public boolean isTerminated()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### listConstraints(FolderName parent)

    public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(FolderName parent)

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       FolderName parent = FolderName.of("[FOLDER]");
       for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.FolderName` Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse` |   |

### listConstraints(ListConstraintsRequest request)

    public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(ListConstraintsRequest request)

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListConstraintsRequest request =
           ListConstraintsRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (Constraint element : orgPolicyClient.listConstraints(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListConstraintsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse` |   |

### listConstraints(OrganizationName parent)

    public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(OrganizationName parent)

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
       for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrganizationName` Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse` |   |

### listConstraints(ProjectName parent)

    public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(ProjectName parent)

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ProjectName parent = ProjectName.of("[PROJECT]");
       for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ProjectName` Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse` |   |

### listConstraints(String parent)

    public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(String parent)

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String parent = ProjectName.of("[PROJECT]").toString();
       for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse` |   |

### listConstraintsCallable()

    public final UnaryCallable<ListConstraintsRequest,ListConstraintsResponse> listConstraintsCallable()

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListConstraintsRequest request =
           ListConstraintsRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListConstraintsResponse response = orgPolicyClient.listConstraintsCallable().call(request);
         for (Constraint element : response.getConstraintsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListConstraintsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListConstraintsResponse>` |   |

### listConstraintsPagedCallable()

    public final UnaryCallable<ListConstraintsRequest,OrgPolicyClient.ListConstraintsPagedResponse> listConstraintsPagedCallable()

Lists constraints that could be applied on the specified resource.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListConstraintsRequest request =
           ListConstraintsRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       ApiFuture<Constraint> future =
           orgPolicyClient.listConstraintsPagedCallable().futureCall(request);
       // Do something.
       for (Constraint element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListConstraintsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse>` |   |

### listCustomConstraints(ListCustomConstraintsRequest request)

    public final OrgPolicyClient.ListCustomConstraintsPagedResponse listCustomConstraints(ListCustomConstraintsRequest request)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListCustomConstraintsRequest request =
           ListCustomConstraintsRequest.newBuilder()
               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (CustomConstraint element : orgPolicyClient.listCustomConstraints(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse` |   |

### listCustomConstraints(OrganizationName parent)

    public final OrgPolicyClient.ListCustomConstraintsPagedResponse listCustomConstraints(OrganizationName parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
       for (CustomConstraint element : orgPolicyClient.listCustomConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrganizationName` Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms: - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse` |   |

### listCustomConstraints(String parent)

    public final OrgPolicyClient.ListCustomConstraintsPagedResponse listCustomConstraints(String parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String parent = OrganizationName.of("[ORGANIZATION]").toString();
       for (CustomConstraint element : orgPolicyClient.listCustomConstraints(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The target Google Cloud resource that parents the set of custom constraints that will be returned from this call. Must be in one of the following forms: - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse` |   |

### listCustomConstraintsCallable()

    public final UnaryCallable<ListCustomConstraintsRequest,ListCustomConstraintsResponse> listCustomConstraintsCallable()

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListCustomConstraintsRequest request =
           ListCustomConstraintsRequest.newBuilder()
               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListCustomConstraintsResponse response =
             orgPolicyClient.listCustomConstraintsCallable().call(request);
         for (CustomConstraint element : response.getCustomConstraintsList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse>` |   |

### listCustomConstraintsPagedCallable()

    public final UnaryCallable<ListCustomConstraintsRequest,OrgPolicyClient.ListCustomConstraintsPagedResponse> listCustomConstraintsPagedCallable()

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListCustomConstraintsRequest request =
           ListCustomConstraintsRequest.newBuilder()
               .setParent(OrganizationName.of("[ORGANIZATION]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       ApiFuture<CustomConstraint> future =
           orgPolicyClient.listCustomConstraintsPagedCallable().futureCall(request);
       // Do something.
       for (CustomConstraint element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse>` |   |

### listPolicies(FolderName parent)

    public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(FolderName parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       FolderName parent = FolderName.of("[FOLDER]");
       for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.FolderName` Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse` |   |

### listPolicies(ListPoliciesRequest request)

    public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListPoliciesRequest request =
           ListPoliciesRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       for (Policy element : orgPolicyClient.listPolicies(request).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListPoliciesRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse` |   |

### listPolicies(OrganizationName parent)

    public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(OrganizationName parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
       for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrganizationName` Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse` |   |

### listPolicies(ProjectName parent)

    public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(ProjectName parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ProjectName parent = ProjectName.of("[PROJECT]");
       for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ProjectName` Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse` |   |

### listPolicies(String parent)

    public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(String parent)

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       String parent = ProjectName.of("[PROJECT]").toString();
       for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `parent` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` Required. The target Google Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms: - `projects/{project_number}` - `projects/{project_id}` - `folders/{folder_id}` - `organizations/{organization_id}` <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse` |   |

### listPoliciesCallable()

    public final UnaryCallable<ListPoliciesRequest,ListPoliciesResponse> listPoliciesCallable()

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListPoliciesRequest request =
           ListPoliciesRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       while (true) {
         ListPoliciesResponse response = orgPolicyClient.listPoliciesCallable().call(request);
         for (Policy element : response.getPoliciesList()) {
           // doThingsWith(element);
         }
         String nextPageToken = response.getNextPageToken();
         if (!Strings.isNullOrEmpty(nextPageToken)) {
           request = request.toBuilder().setPageToken(nextPageToken).build();
         } else {
           break;
         }
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListPoliciesRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListPoliciesResponse>` |   |

### listPoliciesPagedCallable()

    public final UnaryCallable<ListPoliciesRequest,OrgPolicyClient.ListPoliciesPagedResponse> listPoliciesPagedCallable()

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

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       ListPoliciesRequest request =
           ListPoliciesRequest.newBuilder()
               .setParent(ProjectName.of("[PROJECT]").toString())
               .setPageSize(883849137)
               .setPageToken("pageToken873572522")
               .build();
       ApiFuture<Policy> future = orgPolicyClient.listPoliciesPagedCallable().futureCall(request);
       // Do something.
       for (Policy element : future.get().iterateAll()) {
         // doThingsWith(element);
       }
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.ListPoliciesRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse>` |   |

### shutdown()

    public void shutdown()

### shutdownNow()

    public void shutdownNow()

### updateCustomConstraint(CustomConstraint customConstraint)

    public final CustomConstraint updateCustomConstraint(CustomConstraint customConstraint)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
       CustomConstraint response = orgPolicyClient.updateCustomConstraint(customConstraint);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `customConstraint` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` Required. `CustomConstraint` to update. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### updateCustomConstraint(UpdateCustomConstraintRequest request)

    public final CustomConstraint updateCustomConstraint(UpdateCustomConstraintRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       UpdateCustomConstraintRequest request =
           UpdateCustomConstraintRequest.newBuilder()
               .setCustomConstraint(CustomConstraint.newBuilder().build())
               .build();
       CustomConstraint response = orgPolicyClient.updateCustomConstraint(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint` |   |

### updateCustomConstraintCallable()

    public final UnaryCallable<UpdateCustomConstraintRequest,CustomConstraint> updateCustomConstraintCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       UpdateCustomConstraintRequest request =
           UpdateCustomConstraintRequest.newBuilder()
               .setCustomConstraint(CustomConstraint.newBuilder().build())
               .build();
       ApiFuture<CustomConstraint> future =
           orgPolicyClient.updateCustomConstraintCallable().futureCall(request);
       // Do something.
       CustomConstraint response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.CustomConstraint>` |   |

### updatePolicy(Policy policy)

    public final Policy updatePolicy(Policy policy)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       Policy policy = Policy.newBuilder().build();
       Policy response = orgPolicyClient.updatePolicy(policy);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `policy` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` Required. Policy to update. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### updatePolicy(UpdatePolicyRequest request)

    public final Policy updatePolicy(UpdatePolicyRequest request)

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       UpdatePolicyRequest request =
           UpdatePolicyRequest.newBuilder()
               .setPolicy(Policy.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       Policy response = orgPolicyClient.updatePolicy(request);
     }
     
| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.UpdatePolicyRequest` The request object containing all of the parameters for the API call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy` |   |

### updatePolicyCallable()

    public final UnaryCallable<UpdatePolicyRequest,Policy> updatePolicyCallable()

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.

Sample code:


     // This snippet has been automatically generated and should be regarded as a code template only.
     // It will require modifications to work:
     // - It may require correct/in-range values for request initialization.
     // - It may require specifying regional endpoints when creating the service client as shown in
     // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
     try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
       UpdatePolicyRequest request =
           UpdatePolicyRequest.newBuilder()
               .setPolicy(Policy.newBuilder().build())
               .setUpdateMask(FieldMask.newBuilder().build())
               .build();
       ApiFuture<Policy> future = orgPolicyClient.updatePolicyCallable().futureCall(request);
       // Do something.
       Policy response = future.get();
     }
     
| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.rpc.UnaryCallable.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.UpdatePolicyRequest,https://docs.cloud.google.com/java/docs/reference/google-cloud-orgpolicy/latest/com.google.cloud.orgpolicy.v2.Policy>` |   |