Class DataPolicyServiceClient

java.lang.Object
com.google.cloud.bigquery.datapolicies.v2beta1.DataPolicyServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@BetaApi @Generated("by gapic-generator-java") public class DataPolicyServiceClient extends Object implements BackgroundResource
Service Description: Data Policy Service provides APIs for managing the BigQuery Data Policy.

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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   DataPolicy dataPolicy = DataPolicy.newBuilder().build();
   String dataPolicyId = "dataPolicyId1874146231";
   DataPolicy response =
       dataPolicyServiceClient.createDataPolicy(parent, dataPolicy, dataPolicyId);
 }
 

Note: close() needs to be called on the DataPolicyServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

CreateDataPolicy

Creates a new data policy under a project with the given `data_policy_id` (used as the display name), and data policy type.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createDataPolicy(CreateDataPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createDataPolicy(LocationName parent, DataPolicy dataPolicy, String dataPolicyId)

  • createDataPolicy(String parent, DataPolicy dataPolicy, String dataPolicyId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createDataPolicyCallable()

AddGrantees

Adds new grantees to a data policy. The new grantees will be added to the existing grantees. If the request contains a duplicate grantee, the grantee will be ignored. If the request contains a grantee that already exists, the grantee will be ignored.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • addGrantees(AddGranteesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • addGrantees(DataPolicyName dataPolicy, List<String> grantees)

  • addGrantees(String dataPolicy, List<String> grantees)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • addGranteesCallable()

RemoveGrantees

Removes grantees from a data policy. The grantees will be removed from the existing grantees. If the request contains a grantee that does not exist, the grantee will be ignored.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • removeGrantees(RemoveGranteesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • removeGrantees(DataPolicyName dataPolicy, List<String> grantees)

  • removeGrantees(String dataPolicy, List<String> grantees)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • removeGranteesCallable()

UpdateDataPolicy

Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateDataPolicy(UpdateDataPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateDataPolicy(DataPolicy dataPolicy, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateDataPolicyCallable()

DeleteDataPolicy

Deletes the data policy specified by its resource name.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteDataPolicy(DeleteDataPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteDataPolicy(DataPolicyName name)

  • deleteDataPolicy(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.

  • deleteDataPolicyCallable()

GetDataPolicy

Gets the data policy specified by its resource name.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getDataPolicy(GetDataPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getDataPolicy(DataPolicyName name)

  • getDataPolicy(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.

  • getDataPolicyCallable()

ListDataPolicies

List all of the data policies in the specified parent project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listDataPolicies(ListDataPoliciesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listDataPolicies(LocationName parent)

  • listDataPolicies(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.

  • listDataPoliciesPagedCallable()

  • listDataPoliciesCallable()

GetIamPolicy

Gets the IAM policy for the specified data policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getIamPolicy(GetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getIamPolicyCallable()

SetIamPolicy

Sets the IAM policy for the specified data policy.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setIamPolicy(SetIamPolicyRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setIamPolicyCallable()

TestIamPermissions

Returns the caller's permission on the specified data policy resource.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • testIamPermissions(TestIamPermissionsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • testIamPermissionsCallable()

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 DataPolicyServiceSettings 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
 DataPolicyServiceSettings dataPolicyServiceSettings =
     DataPolicyServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 DataPolicyServiceClient dataPolicyServiceClient =
     DataPolicyServiceClient.create(dataPolicyServiceSettings);
 

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
 DataPolicyServiceSettings dataPolicyServiceSettings =
     DataPolicyServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 DataPolicyServiceClient dataPolicyServiceClient =
     DataPolicyServiceClient.create(dataPolicyServiceSettings);
 

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
 DataPolicyServiceSettings dataPolicyServiceSettings =
     DataPolicyServiceSettings.newHttpJsonBuilder().build();
 DataPolicyServiceClient dataPolicyServiceClient =
     DataPolicyServiceClient.create(dataPolicyServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

  • Constructor Details

    • DataPolicyServiceClient

      protected DataPolicyServiceClient(DataPolicyServiceSettings settings) throws IOException
      Constructs an instance of DataPolicyServiceClient, 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.
      Throws:
      IOException
    • DataPolicyServiceClient

      protected DataPolicyServiceClient(DataPolicyServiceStub stub)
  • Method Details

    • create

      public static final DataPolicyServiceClient create() throws IOException
      Constructs an instance of DataPolicyServiceClient with default settings.
      Throws:
      IOException
    • create

      public static final DataPolicyServiceClient create(DataPolicyServiceSettings settings) throws IOException
      Constructs an instance of DataPolicyServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
      Throws:
      IOException
    • create

      public static final DataPolicyServiceClient create(DataPolicyServiceStub stub)
      Constructs an instance of DataPolicyServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(DataPolicyServiceSettings).
    • getSettings

      public final DataPolicyServiceSettings getSettings()
    • getStub

      public DataPolicyServiceStub getStub()
    • createDataPolicy

      public final DataPolicy createDataPolicy(LocationName parent, DataPolicy dataPolicy, String dataPolicyId)
      Creates a new data policy under a project with the given `data_policy_id` (used as the display name), and data policy type.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         DataPolicy dataPolicy = DataPolicy.newBuilder().build();
         String dataPolicyId = "dataPolicyId1874146231";
         DataPolicy response =
             dataPolicyServiceClient.createDataPolicy(parent, dataPolicy, dataPolicyId);
       }
       
      Parameters:
      parent - Required. Resource name of the project that the data policy will belong to. The format is `projects/{project_number}/locations/{location_id}`.
      dataPolicy - Required. The data policy to create. The `name` field does not need to be provided for the data policy creation.
      dataPolicyId - Required. User-assigned (human readable) ID of the data policy that needs to be unique within a project. Used as {data_policy_id} in part of the resource name.
      Throws:
      ApiException - if the remote call fails
    • createDataPolicy

      public final DataPolicy createDataPolicy(String parent, DataPolicy dataPolicy, String dataPolicyId)
      Creates a new data policy under a project with the given `data_policy_id` (used as the display name), and data policy type.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         DataPolicy dataPolicy = DataPolicy.newBuilder().build();
         String dataPolicyId = "dataPolicyId1874146231";
         DataPolicy response =
             dataPolicyServiceClient.createDataPolicy(parent, dataPolicy, dataPolicyId);
       }
       
      Parameters:
      parent - Required. Resource name of the project that the data policy will belong to. The format is `projects/{project_number}/locations/{location_id}`.
      dataPolicy - Required. The data policy to create. The `name` field does not need to be provided for the data policy creation.
      dataPolicyId - Required. User-assigned (human readable) ID of the data policy that needs to be unique within a project. Used as {data_policy_id} in part of the resource name.
      Throws:
      ApiException - if the remote call fails
    • createDataPolicy

      public final DataPolicy createDataPolicy(CreateDataPolicyRequest request)
      Creates a new data policy under a project with the given `data_policy_id` (used as the display name), and data policy type.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         CreateDataPolicyRequest request =
             CreateDataPolicyRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setDataPolicyId("dataPolicyId1874146231")
                 .setDataPolicy(DataPolicy.newBuilder().build())
                 .build();
         DataPolicy response = dataPolicyServiceClient.createDataPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • createDataPolicyCallable

      public final UnaryCallable<CreateDataPolicyRequest,DataPolicy> createDataPolicyCallable()
      Creates a new data policy under a project with the given `data_policy_id` (used as the display name), and data policy type.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         CreateDataPolicyRequest request =
             CreateDataPolicyRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setDataPolicyId("dataPolicyId1874146231")
                 .setDataPolicy(DataPolicy.newBuilder().build())
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.createDataPolicyCallable().futureCall(request);
         // Do something.
         DataPolicy response = future.get();
       }
       
    • addGrantees

      public final DataPolicy addGrantees(DataPolicyName dataPolicy, List<String> grantees)
      Adds new grantees to a data policy. The new grantees will be added to the existing grantees. If the request contains a duplicate grantee, the grantee will be ignored. If the request contains a grantee that already exists, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DataPolicyName dataPolicy = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]");
         List<String> grantees = new ArrayList<>();
         DataPolicy response = dataPolicyServiceClient.addGrantees(dataPolicy, grantees);
       }
       
      Parameters:
      dataPolicy - Required. Resource name of this data policy, in the format of `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
      grantees - Required. IAM principal that should be granted Fine Grained Access to the underlying data goverened by the data policy. The target data policy is determined by the `data_policy` field.

      Uses the [IAM V2 principal syntax](https://cloud.google.com/iam/docs/principal-identifiers#v2). Supported principal types:

      • User
      • Group
      • Service account
      Throws:
      ApiException - if the remote call fails
    • addGrantees

      public final DataPolicy addGrantees(String dataPolicy, List<String> grantees)
      Adds new grantees to a data policy. The new grantees will be added to the existing grantees. If the request contains a duplicate grantee, the grantee will be ignored. If the request contains a grantee that already exists, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String dataPolicy = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString();
         List<String> grantees = new ArrayList<>();
         DataPolicy response = dataPolicyServiceClient.addGrantees(dataPolicy, grantees);
       }
       
      Parameters:
      dataPolicy - Required. Resource name of this data policy, in the format of `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
      grantees - Required. IAM principal that should be granted Fine Grained Access to the underlying data goverened by the data policy. The target data policy is determined by the `data_policy` field.

      Uses the [IAM V2 principal syntax](https://cloud.google.com/iam/docs/principal-identifiers#v2). Supported principal types:

      • User
      • Group
      • Service account
      Throws:
      ApiException - if the remote call fails
    • addGrantees

      public final DataPolicy addGrantees(AddGranteesRequest request)
      Adds new grantees to a data policy. The new grantees will be added to the existing grantees. If the request contains a duplicate grantee, the grantee will be ignored. If the request contains a grantee that already exists, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         AddGranteesRequest request =
             AddGranteesRequest.newBuilder()
                 .setDataPolicy(
                     DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllGrantees(new ArrayList<String>())
                 .build();
         DataPolicy response = dataPolicyServiceClient.addGrantees(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • addGranteesCallable

      public final UnaryCallable<AddGranteesRequest,DataPolicy> addGranteesCallable()
      Adds new grantees to a data policy. The new grantees will be added to the existing grantees. If the request contains a duplicate grantee, the grantee will be ignored. If the request contains a grantee that already exists, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         AddGranteesRequest request =
             AddGranteesRequest.newBuilder()
                 .setDataPolicy(
                     DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllGrantees(new ArrayList<String>())
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.addGranteesCallable().futureCall(request);
         // Do something.
         DataPolicy response = future.get();
       }
       
    • removeGrantees

      public final DataPolicy removeGrantees(DataPolicyName dataPolicy, List<String> grantees)
      Removes grantees from a data policy. The grantees will be removed from the existing grantees. If the request contains a grantee that does not exist, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DataPolicyName dataPolicy = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]");
         List<String> grantees = new ArrayList<>();
         DataPolicy response = dataPolicyServiceClient.removeGrantees(dataPolicy, grantees);
       }
       
      Parameters:
      dataPolicy - Required. Resource name of this data policy, in the format of `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
      grantees - Required. IAM principal that should be revoked from Fine Grained Access to the underlying data goverened by the data policy. The target data policy is determined by the `data_policy` field.

      Uses the [IAM V2 principal syntax](https://cloud.google.com/iam/docs/principal-identifiers#v2). Supported principal types:

      • User
      • Group
      • Service account
      Throws:
      ApiException - if the remote call fails
    • removeGrantees

      public final DataPolicy removeGrantees(String dataPolicy, List<String> grantees)
      Removes grantees from a data policy. The grantees will be removed from the existing grantees. If the request contains a grantee that does not exist, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String dataPolicy = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString();
         List<String> grantees = new ArrayList<>();
         DataPolicy response = dataPolicyServiceClient.removeGrantees(dataPolicy, grantees);
       }
       
      Parameters:
      dataPolicy - Required. Resource name of this data policy, in the format of `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
      grantees - Required. IAM principal that should be revoked from Fine Grained Access to the underlying data goverened by the data policy. The target data policy is determined by the `data_policy` field.

      Uses the [IAM V2 principal syntax](https://cloud.google.com/iam/docs/principal-identifiers#v2). Supported principal types:

      • User
      • Group
      • Service account
      Throws:
      ApiException - if the remote call fails
    • removeGrantees

      public final DataPolicy removeGrantees(RemoveGranteesRequest request)
      Removes grantees from a data policy. The grantees will be removed from the existing grantees. If the request contains a grantee that does not exist, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         RemoveGranteesRequest request =
             RemoveGranteesRequest.newBuilder()
                 .setDataPolicy(
                     DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllGrantees(new ArrayList<String>())
                 .build();
         DataPolicy response = dataPolicyServiceClient.removeGrantees(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • removeGranteesCallable

      public final UnaryCallable<RemoveGranteesRequest,DataPolicy> removeGranteesCallable()
      Removes grantees from a data policy. The grantees will be removed from the existing grantees. If the request contains a grantee that does not exist, the grantee will be ignored.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         RemoveGranteesRequest request =
             RemoveGranteesRequest.newBuilder()
                 .setDataPolicy(
                     DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllGrantees(new ArrayList<String>())
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.removeGranteesCallable().futureCall(request);
         // Do something.
         DataPolicy response = future.get();
       }
       
    • updateDataPolicy

      public final DataPolicy updateDataPolicy(DataPolicy dataPolicy, com.google.protobuf.FieldMask updateMask)
      Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DataPolicy dataPolicy = DataPolicy.newBuilder().build();
         FieldMask updateMask = FieldMask.newBuilder().build();
         DataPolicy response = dataPolicyServiceClient.updateDataPolicy(dataPolicy, updateMask);
       }
       
      Parameters:
      dataPolicy - Required. Update the data policy's metadata.

      The target data policy is determined by the `name` field. Other fields are updated to the specified values based on the field masks.

      updateMask - Optional. The update mask applies to the resource. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask If not set, defaults to all of the fields that are allowed to update.

      Updates to the `name` and `dataPolicyId` fields are not allowed.

      Throws:
      ApiException - if the remote call fails
    • updateDataPolicy

      public final DataPolicy updateDataPolicy(UpdateDataPolicyRequest request)
      Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         UpdateDataPolicyRequest request =
             UpdateDataPolicyRequest.newBuilder()
                 .setDataPolicy(DataPolicy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         DataPolicy response = dataPolicyServiceClient.updateDataPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • updateDataPolicyCallable

      public final UnaryCallable<UpdateDataPolicyRequest,DataPolicy> updateDataPolicyCallable()
      Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         UpdateDataPolicyRequest request =
             UpdateDataPolicyRequest.newBuilder()
                 .setDataPolicy(DataPolicy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.updateDataPolicyCallable().futureCall(request);
         // Do something.
         DataPolicy response = future.get();
       }
       
    • deleteDataPolicy

      public final void deleteDataPolicy(DataPolicyName name)
      Deletes the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DataPolicyName name = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]");
         dataPolicyServiceClient.deleteDataPolicy(name);
       }
       
      Parameters:
      name - Required. Resource name of the data policy to delete. Format is `projects/{project_number}/locations/{location_id}/dataPolicies/{id}`.
      Throws:
      ApiException - if the remote call fails
    • deleteDataPolicy

      public final void deleteDataPolicy(String name)
      Deletes the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String name = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString();
         dataPolicyServiceClient.deleteDataPolicy(name);
       }
       
      Parameters:
      name - Required. Resource name of the data policy to delete. Format is `projects/{project_number}/locations/{location_id}/dataPolicies/{id}`.
      Throws:
      ApiException - if the remote call fails
    • deleteDataPolicy

      public final void deleteDataPolicy(DeleteDataPolicyRequest request)
      Deletes the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DeleteDataPolicyRequest request =
             DeleteDataPolicyRequest.newBuilder()
                 .setName(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .build();
         dataPolicyServiceClient.deleteDataPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • deleteDataPolicyCallable

      public final UnaryCallable<DeleteDataPolicyRequest,com.google.protobuf.Empty> deleteDataPolicyCallable()
      Deletes the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DeleteDataPolicyRequest request =
             DeleteDataPolicyRequest.newBuilder()
                 .setName(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .build();
         ApiFuture<Empty> future =
             dataPolicyServiceClient.deleteDataPolicyCallable().futureCall(request);
         // Do something.
         future.get();
       }
       
    • getDataPolicy

      public final DataPolicy getDataPolicy(DataPolicyName name)
      Gets the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         DataPolicyName name = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]");
         DataPolicy response = dataPolicyServiceClient.getDataPolicy(name);
       }
       
      Parameters:
      name - Required. Resource name of the requested data policy. Format is `projects/{project_number}/locations/{location_id}/dataPolicies/{id}`.
      Throws:
      ApiException - if the remote call fails
    • getDataPolicy

      public final DataPolicy getDataPolicy(String name)
      Gets the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String name = DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString();
         DataPolicy response = dataPolicyServiceClient.getDataPolicy(name);
       }
       
      Parameters:
      name - Required. Resource name of the requested data policy. Format is `projects/{project_number}/locations/{location_id}/dataPolicies/{id}`.
      Throws:
      ApiException - if the remote call fails
    • getDataPolicy

      public final DataPolicy getDataPolicy(GetDataPolicyRequest request)
      Gets the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         GetDataPolicyRequest request =
             GetDataPolicyRequest.newBuilder()
                 .setName(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .build();
         DataPolicy response = dataPolicyServiceClient.getDataPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getDataPolicyCallable

      public final UnaryCallable<GetDataPolicyRequest,DataPolicy> getDataPolicyCallable()
      Gets the data policy specified by its resource name.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         GetDataPolicyRequest request =
             GetDataPolicyRequest.newBuilder()
                 .setName(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.getDataPolicyCallable().futureCall(request);
         // Do something.
         DataPolicy response = future.get();
       }
       
    • listDataPolicies

      List all of the data policies in the specified parent project.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
         for (DataPolicy element : dataPolicyServiceClient.listDataPolicies(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. Resource name of the project for which to list data policies. Format is `projects/{project_number}/locations/{location_id}`.
      Throws:
      ApiException - if the remote call fails
    • listDataPolicies

      public final DataPolicyServiceClient.ListDataPoliciesPagedResponse listDataPolicies(String parent)
      List all of the data policies in the specified parent project.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
         for (DataPolicy element : dataPolicyServiceClient.listDataPolicies(parent).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      parent - Required. Resource name of the project for which to list data policies. Format is `projects/{project_number}/locations/{location_id}`.
      Throws:
      ApiException - if the remote call fails
    • listDataPolicies

      List all of the data policies in the specified parent project.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         ListDataPoliciesRequest request =
             ListDataPoliciesRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         for (DataPolicy element : dataPolicyServiceClient.listDataPolicies(request).iterateAll()) {
           // doThingsWith(element);
         }
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • listDataPoliciesPagedCallable

      List all of the data policies in the specified parent project.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         ListDataPoliciesRequest request =
             ListDataPoliciesRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         ApiFuture<DataPolicy> future =
             dataPolicyServiceClient.listDataPoliciesPagedCallable().futureCall(request);
         // Do something.
         for (DataPolicy element : future.get().iterateAll()) {
           // doThingsWith(element);
         }
       }
       
    • listDataPoliciesCallable

      public final UnaryCallable<ListDataPoliciesRequest,ListDataPoliciesResponse> listDataPoliciesCallable()
      List all of the data policies in the specified parent project.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         ListDataPoliciesRequest request =
             ListDataPoliciesRequest.newBuilder()
                 .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
                 .setPageSize(883849137)
                 .setPageToken("pageToken873572522")
                 .build();
         while (true) {
           ListDataPoliciesResponse response =
               dataPolicyServiceClient.listDataPoliciesCallable().call(request);
           for (DataPolicy element : response.getDataPoliciesList()) {
             // doThingsWith(element);
           }
           String nextPageToken = response.getNextPageToken();
           if (!Strings.isNullOrEmpty(nextPageToken)) {
             request = request.toBuilder().setPageToken(nextPageToken).build();
           } else {
             break;
           }
         }
       }
       
    • getIamPolicy

      public final Policy getIamPolicy(GetIamPolicyRequest request)
      Gets the IAM policy for the specified data policy.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         Policy response = dataPolicyServiceClient.getIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • getIamPolicyCallable

      public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()
      Gets the IAM policy for the specified data policy.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         GetIamPolicyRequest request =
             GetIamPolicyRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .setOptions(GetPolicyOptions.newBuilder().build())
                 .build();
         ApiFuture<Policy> future = dataPolicyServiceClient.getIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • setIamPolicy

      public final Policy setIamPolicy(SetIamPolicyRequest request)
      Sets the IAM policy for the specified data policy.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         Policy response = dataPolicyServiceClient.setIamPolicy(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • setIamPolicyCallable

      public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
      Sets the IAM policy for the specified data policy.

      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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         SetIamPolicyRequest request =
             SetIamPolicyRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .setPolicy(Policy.newBuilder().build())
                 .setUpdateMask(FieldMask.newBuilder().build())
                 .build();
         ApiFuture<Policy> future = dataPolicyServiceClient.setIamPolicyCallable().futureCall(request);
         // Do something.
         Policy response = future.get();
       }
       
    • testIamPermissions

      public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
      Returns the caller's permission on the specified data policy 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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         TestIamPermissionsResponse response = dataPolicyServiceClient.testIamPermissions(request);
       }
       
      Parameters:
      request - The request object containing all of the parameters for the API call.
      Throws:
      ApiException - if the remote call fails
    • testIamPermissionsCallable

      public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()
      Returns the caller's permission on the specified data policy 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 (DataPolicyServiceClient dataPolicyServiceClient = DataPolicyServiceClient.create()) {
         TestIamPermissionsRequest request =
             TestIamPermissionsRequest.newBuilder()
                 .setResource(DataPolicyName.of("[PROJECT]", "[LOCATION]", "[DATA_POLICY]").toString())
                 .addAllPermissions(new ArrayList<String>())
                 .build();
         ApiFuture<TestIamPermissionsResponse> future =
             dataPolicyServiceClient.testIamPermissionsCallable().futureCall(request);
         // Do something.
         TestIamPermissionsResponse response = future.get();
       }
       
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException