com.google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient Maven / Gradle / Ivy
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.bigquery.datapolicies.v1;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.bigquery.datapolicies.v1.stub.DataPolicyServiceStub;
import com.google.cloud.bigquery.datapolicies.v1.stub.DataPolicyServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* Service Description: Data Policy Service provides APIs for managing the label-policy bindings.
*
* 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:
*
*
{@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();
* DataPolicy response = dataPolicyServiceClient.createDataPolicy(parent, dataPolicy);
* }
* }
*
* 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().
*
*
The surface of this class includes several types of Java methods for each of the API's
* methods:
*
*
* - A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
*
- A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
*
- A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
*
*
* 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:
*
*
{@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
* DataPolicyServiceSettings dataPolicyServiceSettings =
* DataPolicyServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* DataPolicyServiceClient dataPolicyServiceClient =
* DataPolicyServiceClient.create(dataPolicyServiceSettings);
* }
*
* To customize the endpoint:
*
*
{@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
* 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:
*
*
{@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
* DataPolicyServiceSettings dataPolicyServiceSettings =
* DataPolicyServiceSettings.newHttpJsonBuilder().build();
* DataPolicyServiceClient dataPolicyServiceClient =
* DataPolicyServiceClient.create(dataPolicyServiceSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class DataPolicyServiceClient implements BackgroundResource {
private final DataPolicyServiceSettings settings;
private final DataPolicyServiceStub stub;
/** Constructs an instance of DataPolicyServiceClient with default settings. */
public static final DataPolicyServiceClient create() throws IOException {
return create(DataPolicyServiceSettings.newBuilder().build());
}
/**
* 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.
*/
public static final DataPolicyServiceClient create(DataPolicyServiceSettings settings)
throws IOException {
return new DataPolicyServiceClient(settings);
}
/**
* Constructs an instance of DataPolicyServiceClient, using the given stub for making calls. This
* is for advanced usage - prefer using create(DataPolicyServiceSettings).
*/
public static final DataPolicyServiceClient create(DataPolicyServiceStub stub) {
return new DataPolicyServiceClient(stub);
}
/**
* 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.
*/
protected DataPolicyServiceClient(DataPolicyServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((DataPolicyServiceStubSettings) settings.getStubSettings()).createStub();
}
protected DataPolicyServiceClient(DataPolicyServiceStub stub) {
this.settings = null;
this.stub = stub;
}
public final DataPolicyServiceSettings getSettings() {
return settings;
}
public DataPolicyServiceStub getStub() {
return stub;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a new data policy under a project with the given `dataPolicyId` (used as the display
* name), policy tag, and data policy type.
*
*
Sample code:
*
*
{@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();
* DataPolicy response = dataPolicyServiceClient.createDataPolicy(parent, dataPolicy);
* }
* }
*
* @param parent Required. Resource name of the project that the data policy will belong to. The
* format is `projects/{project_number}/locations/{location_id}`.
* @param dataPolicy Required. The data policy to create. The `name` field does not need to be
* provided for the data policy creation.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy createDataPolicy(LocationName parent, DataPolicy dataPolicy) {
CreateDataPolicyRequest request =
CreateDataPolicyRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setDataPolicy(dataPolicy)
.build();
return createDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a new data policy under a project with the given `dataPolicyId` (used as the display
* name), policy tag, and data policy type.
*
* Sample code:
*
*
{@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();
* DataPolicy response = dataPolicyServiceClient.createDataPolicy(parent, dataPolicy);
* }
* }
*
* @param parent Required. Resource name of the project that the data policy will belong to. The
* format is `projects/{project_number}/locations/{location_id}`.
* @param dataPolicy Required. The data policy to create. The `name` field does not need to be
* provided for the data policy creation.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy createDataPolicy(String parent, DataPolicy dataPolicy) {
CreateDataPolicyRequest request =
CreateDataPolicyRequest.newBuilder().setParent(parent).setDataPolicy(dataPolicy).build();
return createDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a new data policy under a project with the given `dataPolicyId` (used as the display
* name), policy tag, and data policy type.
*
* Sample code:
*
*
{@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())
* .setDataPolicy(DataPolicy.newBuilder().build())
* .build();
* DataPolicy response = dataPolicyServiceClient.createDataPolicy(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy createDataPolicy(CreateDataPolicyRequest request) {
return createDataPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a new data policy under a project with the given `dataPolicyId` (used as the display
* name), policy tag, and data policy type.
*
* Sample code:
*
*
{@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())
* .setDataPolicy(DataPolicy.newBuilder().build())
* .build();
* ApiFuture future =
* dataPolicyServiceClient.createDataPolicyCallable().futureCall(request);
* // Do something.
* DataPolicy response = future.get();
* }
* }
*/
public final UnaryCallable createDataPolicyCallable() {
return stub.createDataPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the metadata for an existing data policy. The target data policy can be specified by
* the resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param 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.
* @param updateMask 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 com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy updateDataPolicy(DataPolicy dataPolicy, FieldMask updateMask) {
UpdateDataPolicyRequest request =
UpdateDataPolicyRequest.newBuilder()
.setDataPolicy(dataPolicy)
.setUpdateMask(updateMask)
.build();
return updateDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the metadata for an existing data policy. The target data policy can be specified by
* the resource name.
*
*
Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy updateDataPolicy(UpdateDataPolicyRequest request) {
return updateDataPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates the metadata for an existing data policy. The target data policy can be specified by
* the resource name.
*
* Sample code:
*
*
{@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 future =
* dataPolicyServiceClient.updateDataPolicyCallable().futureCall(request);
* // Do something.
* DataPolicy response = future.get();
* }
* }
*/
public final UnaryCallable updateDataPolicyCallable() {
return stub.updateDataPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Renames the id (display name) of the specified data policy.
*
* Sample code:
*
*
{@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 = "name3373707";
* String newDataPolicyId = "newDataPolicyId288407927";
* DataPolicy response = dataPolicyServiceClient.renameDataPolicy(name, newDataPolicyId);
* }
* }
*
* @param name Required. Resource name of the data policy to rename. The format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`
* @param newDataPolicyId Required. The new data policy id.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy renameDataPolicy(String name, String newDataPolicyId) {
RenameDataPolicyRequest request =
RenameDataPolicyRequest.newBuilder()
.setName(name)
.setNewDataPolicyId(newDataPolicyId)
.build();
return renameDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Renames the id (display name) of the specified data policy.
*
* Sample code:
*
*
{@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()) {
* RenameDataPolicyRequest request =
* RenameDataPolicyRequest.newBuilder()
* .setName("name3373707")
* .setNewDataPolicyId("newDataPolicyId288407927")
* .build();
* DataPolicy response = dataPolicyServiceClient.renameDataPolicy(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy renameDataPolicy(RenameDataPolicyRequest request) {
return renameDataPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Renames the id (display name) of the specified data policy.
*
* Sample code:
*
*
{@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()) {
* RenameDataPolicyRequest request =
* RenameDataPolicyRequest.newBuilder()
* .setName("name3373707")
* .setNewDataPolicyId("newDataPolicyId288407927")
* .build();
* ApiFuture future =
* dataPolicyServiceClient.renameDataPolicyCallable().futureCall(request);
* // Do something.
* DataPolicy response = future.get();
* }
* }
*/
public final UnaryCallable renameDataPolicyCallable() {
return stub.renameDataPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param name Required. Resource name of the data policy to delete. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDataPolicy(DataPolicyName name) {
DeleteDataPolicyRequest request =
DeleteDataPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param name Required. Resource name of the data policy to delete. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDataPolicy(String name) {
DeleteDataPolicyRequest request = DeleteDataPolicyRequest.newBuilder().setName(name).build();
deleteDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDataPolicy(DeleteDataPolicyRequest request) {
deleteDataPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the data policy specified by its resource name.
*
* Sample code:
*
*
{@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 future =
* dataPolicyServiceClient.deleteDataPolicyCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable deleteDataPolicyCallable() {
return stub.deleteDataPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param name Required. Resource name of the requested data policy. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy getDataPolicy(DataPolicyName name) {
GetDataPolicyRequest request =
GetDataPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return getDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param name Required. Resource name of the requested data policy. Format is
* `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy getDataPolicy(String name) {
GetDataPolicyRequest request = GetDataPolicyRequest.newBuilder().setName(name).build();
return getDataPolicy(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the data policy specified by its resource name.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final DataPolicy getDataPolicy(GetDataPolicyRequest request) {
return getDataPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the data policy specified by its resource name.
*
* Sample code:
*
*
{@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 future =
* dataPolicyServiceClient.getDataPolicyCallable().futureCall(request);
* // Do something.
* DataPolicy response = future.get();
* }
* }
*/
public final UnaryCallable getDataPolicyCallable() {
return stub.getDataPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all of the data policies in the specified parent project.
*
* Sample code:
*
*
{@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);
* }
* }
* }
*
* @param parent Required. Resource name of the project for which to list data policies. Format is
* `projects/{project_number}/locations/{location_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDataPoliciesPagedResponse listDataPolicies(LocationName parent) {
ListDataPoliciesRequest request =
ListDataPoliciesRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.build();
return listDataPolicies(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all of the data policies in the specified parent project.
*
* Sample code:
*
*
{@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);
* }
* }
* }
*
* @param parent Required. Resource name of the project for which to list data policies. Format is
* `projects/{project_number}/locations/{location_id}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDataPoliciesPagedResponse listDataPolicies(String parent) {
ListDataPoliciesRequest request =
ListDataPoliciesRequest.newBuilder().setParent(parent).build();
return listDataPolicies(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all of the data policies in the specified parent project.
*
* Sample code:
*
*
{@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")
* .setFilter("filter-1274492040")
* .build();
* for (DataPolicy element : dataPolicyServiceClient.listDataPolicies(request).iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListDataPoliciesPagedResponse listDataPolicies(ListDataPoliciesRequest request) {
return listDataPoliciesPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all of the data policies in the specified parent project.
*
* Sample code:
*
*
{@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")
* .setFilter("filter-1274492040")
* .build();
* ApiFuture future =
* dataPolicyServiceClient.listDataPoliciesPagedCallable().futureCall(request);
* // Do something.
* for (DataPolicy element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listDataPoliciesPagedCallable() {
return stub.listDataPoliciesPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* List all of the data policies in the specified parent project.
*
* Sample code:
*
*
{@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")
* .setFilter("filter-1274492040")
* .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;
* }
* }
* }
* }
*/
public final UnaryCallable
listDataPoliciesCallable() {
return stub.listDataPoliciesCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for the specified data policy.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getIamPolicy(GetIamPolicyRequest request) {
return getIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Gets the IAM policy for the specified data policy.
*
* Sample code:
*
*
{@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 future = dataPolicyServiceClient.getIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable getIamPolicyCallable() {
return stub.getIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the IAM policy for the specified data policy.
*
* Sample code:
*
*
{@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);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy setIamPolicy(SetIamPolicyRequest request) {
return setIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the IAM policy for the specified data policy.
*
* Sample code:
*
*
{@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 future = dataPolicyServiceClient.setIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable setIamPolicyCallable() {
return stub.setIamPolicyCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the caller's permission on the specified data policy resource.
*
* Sample code:
*
*
{@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())
* .build();
* TestIamPermissionsResponse response = dataPolicyServiceClient.testIamPermissions(request);
* }
* }
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
return testIamPermissionsCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns the caller's permission on the specified data policy resource.
*
* Sample code:
*
*
{@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())
* .build();
* ApiFuture future =
* dataPolicyServiceClient.testIamPermissionsCallable().futureCall(request);
* // Do something.
* TestIamPermissionsResponse response = future.get();
* }
* }
*/
public final UnaryCallable
testIamPermissionsCallable() {
return stub.testIamPermissionsCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListDataPoliciesPagedResponse
extends AbstractPagedListResponse<
ListDataPoliciesRequest,
ListDataPoliciesResponse,
DataPolicy,
ListDataPoliciesPage,
ListDataPoliciesFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListDataPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListDataPoliciesPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListDataPoliciesPagedResponse(ListDataPoliciesPage page) {
super(page, ListDataPoliciesFixedSizeCollection.createEmptyCollection());
}
}
public static class ListDataPoliciesPage
extends AbstractPage<
ListDataPoliciesRequest, ListDataPoliciesResponse, DataPolicy, ListDataPoliciesPage> {
private ListDataPoliciesPage(
PageContext context,
ListDataPoliciesResponse response) {
super(context, response);
}
private static ListDataPoliciesPage createEmptyPage() {
return new ListDataPoliciesPage(null, null);
}
@Override
protected ListDataPoliciesPage createPage(
PageContext context,
ListDataPoliciesResponse response) {
return new ListDataPoliciesPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListDataPoliciesFixedSizeCollection
extends AbstractFixedSizeCollection<
ListDataPoliciesRequest,
ListDataPoliciesResponse,
DataPolicy,
ListDataPoliciesPage,
ListDataPoliciesFixedSizeCollection> {
private ListDataPoliciesFixedSizeCollection(
List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListDataPoliciesFixedSizeCollection createEmptyCollection() {
return new ListDataPoliciesFixedSizeCollection(null, 0);
}
@Override
protected ListDataPoliciesFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListDataPoliciesFixedSizeCollection(pages, collectionSize);
}
}
}