@Generated(value="by gapic-generator-java") public class DataPolicyServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
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();
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().
| Method | Description | Method Variants |
|---|---|---|
CreateDataPolicy |
Creates a new data policy under a project with the given `dataPolicyId` (used as the display name), policy tag, and data policy type. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RenameDataPolicy |
Renames the id (display name) of the specified data policy. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return 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:
// 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
DataPolicyServiceClient.ListDataPoliciesFixedSizeCollection |
static class |
DataPolicyServiceClient.ListDataPoliciesPage |
static class |
DataPolicyServiceClient.ListDataPoliciesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
DataPolicyServiceClient(DataPolicyServiceSettings settings)
Constructs an instance of DataPolicyServiceClient, using the given settings.
|
protected |
DataPolicyServiceClient(DataPolicyServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static DataPolicyServiceClient |
create()
Constructs an instance of DataPolicyServiceClient with default settings.
|
static DataPolicyServiceClient |
create(DataPolicyServiceSettings settings)
Constructs an instance of DataPolicyServiceClient, using the given settings.
|
static DataPolicyServiceClient |
create(DataPolicyServiceStub stub)
Constructs an instance of DataPolicyServiceClient, using the given stub for making calls.
|
DataPolicy |
createDataPolicy(CreateDataPolicyRequest request)
Creates a new data policy under a project with the given `dataPolicyId` (used as the display
name), policy tag, and data policy type.
|
DataPolicy |
createDataPolicy(LocationName parent,
DataPolicy dataPolicy)
Creates a new data policy under a project with the given `dataPolicyId` (used as the display
name), policy tag, and data policy type.
|
DataPolicy |
createDataPolicy(String parent,
DataPolicy dataPolicy)
Creates a new data policy under a project with the given `dataPolicyId` (used as the display
name), policy tag, and data policy type.
|
com.google.api.gax.rpc.UnaryCallable<CreateDataPolicyRequest,DataPolicy> |
createDataPolicyCallable()
Creates a new data policy under a project with the given `dataPolicyId` (used as the display
name), policy tag, and data policy type.
|
void |
deleteDataPolicy(DataPolicyName name)
Deletes the data policy specified by its resource name.
|
void |
deleteDataPolicy(DeleteDataPolicyRequest request)
Deletes the data policy specified by its resource name.
|
void |
deleteDataPolicy(String name)
Deletes the data policy specified by its resource name.
|
com.google.api.gax.rpc.UnaryCallable<DeleteDataPolicyRequest,com.google.protobuf.Empty> |
deleteDataPolicyCallable()
Deletes the data policy specified by its resource name.
|
DataPolicy |
getDataPolicy(DataPolicyName name)
Gets the data policy specified by its resource name.
|
DataPolicy |
getDataPolicy(GetDataPolicyRequest request)
Gets the data policy specified by its resource name.
|
DataPolicy |
getDataPolicy(String name)
Gets the data policy specified by its resource name.
|
com.google.api.gax.rpc.UnaryCallable<GetDataPolicyRequest,DataPolicy> |
getDataPolicyCallable()
Gets the data policy specified by its resource name.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the IAM policy for the specified data policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the IAM policy for the specified data policy.
|
DataPolicyServiceSettings |
getSettings() |
DataPolicyServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
DataPolicyServiceClient.ListDataPoliciesPagedResponse |
listDataPolicies(ListDataPoliciesRequest request)
List all of the data policies in the specified parent project.
|
DataPolicyServiceClient.ListDataPoliciesPagedResponse |
listDataPolicies(LocationName parent)
List all of the data policies in the specified parent project.
|
DataPolicyServiceClient.ListDataPoliciesPagedResponse |
listDataPolicies(String parent)
List all of the data policies in the specified parent project.
|
com.google.api.gax.rpc.UnaryCallable<ListDataPoliciesRequest,ListDataPoliciesResponse> |
listDataPoliciesCallable()
List all of the data policies in the specified parent project.
|
com.google.api.gax.rpc.UnaryCallable<ListDataPoliciesRequest,DataPolicyServiceClient.ListDataPoliciesPagedResponse> |
listDataPoliciesPagedCallable()
List all of the data policies in the specified parent project.
|
DataPolicy |
renameDataPolicy(RenameDataPolicyRequest request)
Renames the id (display name) of the specified data policy.
|
DataPolicy |
renameDataPolicy(String name,
String newDataPolicyId)
Renames the id (display name) of the specified data policy.
|
com.google.api.gax.rpc.UnaryCallable<RenameDataPolicyRequest,DataPolicy> |
renameDataPolicyCallable()
Renames the id (display name) of the specified data policy.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the IAM policy for the specified data policy.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the IAM policy for the specified data policy.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns the caller's permission on the specified data policy resource.
|
com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns the caller's permission on the specified data policy resource.
|
DataPolicy |
updateDataPolicy(DataPolicy dataPolicy,
com.google.protobuf.FieldMask updateMask)
Updates the metadata for an existing data policy.
|
DataPolicy |
updateDataPolicy(UpdateDataPolicyRequest request)
Updates the metadata for an existing data policy.
|
com.google.api.gax.rpc.UnaryCallable<UpdateDataPolicyRequest,DataPolicy> |
updateDataPolicyCallable()
Updates the metadata for an existing data policy.
|
protected DataPolicyServiceClient(DataPolicyServiceSettings settings) throws IOException
IOExceptionprotected DataPolicyServiceClient(DataPolicyServiceStub stub)
public static final DataPolicyServiceClient create() throws IOException
IOExceptionpublic static final DataPolicyServiceClient create(DataPolicyServiceSettings settings) throws IOException
IOExceptionpublic static final DataPolicyServiceClient create(DataPolicyServiceStub stub)
public final DataPolicyServiceSettings getSettings()
public DataPolicyServiceStub getStub()
public final DataPolicy createDataPolicy(LocationName parent, DataPolicy dataPolicy)
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();
DataPolicy response = dataPolicyServiceClient.createDataPolicy(parent, dataPolicy);
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy createDataPolicy(String parent, DataPolicy dataPolicy)
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();
DataPolicy response = dataPolicyServiceClient.createDataPolicy(parent, dataPolicy);
}
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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy createDataPolicy(CreateDataPolicyRequest request)
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())
.setDataPolicy(DataPolicy.newBuilder().build())
.build();
DataPolicy response = dataPolicyServiceClient.createDataPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateDataPolicyRequest,DataPolicy> createDataPolicyCallable()
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())
.setDataPolicy(DataPolicy.newBuilder().build())
.build();
ApiFuture<DataPolicy> future =
dataPolicyServiceClient.createDataPolicyCallable().futureCall(request);
// Do something.
DataPolicy response = future.get();
}
public final DataPolicy updateDataPolicy(DataPolicy dataPolicy, com.google.protobuf.FieldMask updateMask)
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);
}
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 - 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.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy updateDataPolicy(UpdateDataPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateDataPolicyRequest,DataPolicy> updateDataPolicyCallable()
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();
}
public final DataPolicy renameDataPolicy(String name, String newDataPolicyId)
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 = "name3373707";
String newDataPolicyId = "newDataPolicyId288407927";
DataPolicy response = dataPolicyServiceClient.renameDataPolicy(name, newDataPolicyId);
}
name - Required. Resource name of the data policy to rename. The format is
`projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`newDataPolicyId - Required. The new data policy id.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy renameDataPolicy(RenameDataPolicyRequest request)
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()) {
RenameDataPolicyRequest request =
RenameDataPolicyRequest.newBuilder()
.setName("name3373707")
.setNewDataPolicyId("newDataPolicyId288407927")
.build();
DataPolicy response = dataPolicyServiceClient.renameDataPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<RenameDataPolicyRequest,DataPolicy> renameDataPolicyCallable()
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()) {
RenameDataPolicyRequest request =
RenameDataPolicyRequest.newBuilder()
.setName("name3373707")
.setNewDataPolicyId("newDataPolicyId288407927")
.build();
ApiFuture<DataPolicy> future =
dataPolicyServiceClient.renameDataPolicyCallable().futureCall(request);
// Do something.
DataPolicy response = future.get();
}
public final void deleteDataPolicy(DataPolicyName 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);
}
name - Required. Resource name of the data policy to delete. Format is
`projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteDataPolicy(String 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);
}
name - Required. Resource name of the data policy to delete. Format is
`projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteDataPolicy(DeleteDataPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteDataPolicyRequest,com.google.protobuf.Empty> deleteDataPolicyCallable()
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();
}
public final DataPolicy getDataPolicy(DataPolicyName 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);
}
name - Required. Resource name of the requested data policy. Format is
`projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy getDataPolicy(String 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);
}
name - Required. Resource name of the requested data policy. Format is
`projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicy getDataPolicy(GetDataPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetDataPolicyRequest,DataPolicy> getDataPolicyCallable()
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();
}
public final DataPolicyServiceClient.ListDataPoliciesPagedResponse listDataPolicies(LocationName parent)
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);
}
}
parent - Required. Resource name of the project for which to list data policies. Format is
`projects/{project_number}/locations/{location_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicyServiceClient.ListDataPoliciesPagedResponse listDataPolicies(String parent)
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);
}
}
parent - Required. Resource name of the project for which to list data policies. Format is
`projects/{project_number}/locations/{location_id}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final DataPolicyServiceClient.ListDataPoliciesPagedResponse listDataPolicies(ListDataPoliciesRequest request)
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")
.setFilter("filter-1274492040")
.build();
for (DataPolicy element : dataPolicyServiceClient.listDataPolicies(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListDataPoliciesRequest,DataPolicyServiceClient.ListDataPoliciesPagedResponse> listDataPoliciesPagedCallable()
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")
.setFilter("filter-1274492040")
.build();
ApiFuture<DataPolicy> future =
dataPolicyServiceClient.listDataPoliciesPagedCallable().futureCall(request);
// Do something.
for (DataPolicy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListDataPoliciesRequest,ListDataPoliciesResponse> listDataPoliciesCallable()
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")
.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 com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
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();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
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();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
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();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.