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: + * + *
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.newBuilder() + * .setTransportChannelProvider( + * DataPolicyServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + * .build(); + * DataPolicyServiceClient dataPolicyServiceClient = + * DataPolicyServiceClient.create(dataPolicyServiceSettings); + * }+ * + *
Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@BetaApi +@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+ */ + public final UnaryCallablefuture = + * dataPolicyServiceClient.createDataPolicyCallable().futureCall(request); + * // Do something. + * DataPolicy response = future.get(); + * } + * }
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+ */ + public final UnaryCallablefuture = + * dataPolicyServiceClient.updateDataPolicyCallable().futureCall(request); + * // Do something. + * DataPolicy response = future.get(); + * } + * }
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+ */ + public final UnaryCallablefuture = + * dataPolicyServiceClient.deleteDataPolicyCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
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+ */ + public final UnaryCallablefuture = + * dataPolicyServiceClient.getDataPolicyCallable().futureCall(request); + * // Do something. + * DataPolicy response = future.get(); + * } + * }
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") + * .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") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * dataPolicyServiceClient.listDataPoliciesPagedCallable().futureCall(request); + * // Do something. + * for (DataPolicy element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
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") + * .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
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+ */ + public final UnaryCallablefuture = dataPolicyServiceClient.getIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
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+ */ + public final UnaryCallablefuture = dataPolicyServiceClient.setIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
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+ * + * @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. + * + *()) + * .build(); + * TestIamPermissionsResponse response = dataPolicyServiceClient.testIamPermissions(request); + * } + * }
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+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = + * dataPolicyServiceClient.testIamPermissionsCallable().futureCall(request); + * // Do something. + * TestIamPermissionsResponse response = future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of createDataPolicy to 30 seconds: + * + *
{@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.Builder dataPolicyServiceSettingsBuilder = + * DataPolicyServiceSettings.newBuilder(); + * dataPolicyServiceSettingsBuilder + * .createDataPolicySettings() + * .setRetrySettings( + * dataPolicyServiceSettingsBuilder + * .createDataPolicySettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * DataPolicyServiceSettings dataPolicyServiceSettings = dataPolicyServiceSettingsBuilder.build(); + * }+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class DataPolicyServiceSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction The interfaces provided are listed below, along with usage samples.
+ *
+ * ======================= DataPolicyServiceClient =======================
+ *
+ * Service Description: Data Policy Service provides APIs for managing the label-policy bindings.
+ *
+ * Sample for DataPolicyServiceClient:
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public abstract class DataPolicyServiceStub implements BackgroundResource {
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ * For example, to set the total timeout of createDataPolicy to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcDataPolicyServiceCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcDataPolicyServiceStub extends DataPolicyServiceStub {
+ private static final MethodDescriptor This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonDataPolicyServiceCallableFactory
+ implements HttpJsonStubCallableFactory This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonDataPolicyServiceStub extends DataPolicyServiceStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor{@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);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.bigquery.datapolicies.v1beta1;
+
+import javax.annotation.Generated;
diff --git a/java-bigquerydatapolicy/google-cloud-bigquerydatapolicy/src/main/java/com/google/cloud/bigquery/datapolicies/v1beta1/stub/DataPolicyServiceStub.java b/java-bigquerydatapolicy/google-cloud-bigquerydatapolicy/src/main/java/com/google/cloud/bigquery/datapolicies/v1beta1/stub/DataPolicyServiceStub.java
new file mode 100644
index 000000000000..d248853e1491
--- /dev/null
+++ b/java-bigquerydatapolicy/google-cloud-bigquerydatapolicy/src/main/java/com/google/cloud/bigquery/datapolicies/v1beta1/stub/DataPolicyServiceStub.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2022 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.v1beta1.stub;
+
+import static com.google.cloud.bigquery.datapolicies.v1beta1.DataPolicyServiceClient.ListDataPoliciesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest;
+import com.google.cloud.bigquery.datapolicies.v1beta1.DataPolicy;
+import com.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest;
+import com.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest;
+import com.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest;
+import com.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesResponse;
+import com.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest;
+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 javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the DataPolicyService service API.
+ *
+ *
+ *
+ *
+ * {@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
+ * DataPolicyServiceStubSettings.Builder dataPolicyServiceSettingsBuilder =
+ * DataPolicyServiceStubSettings.newBuilder();
+ * dataPolicyServiceSettingsBuilder
+ * .createDataPolicySettings()
+ * .setRetrySettings(
+ * dataPolicyServiceSettingsBuilder
+ * .createDataPolicySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * DataPolicyServiceStubSettings dataPolicyServiceSettings =
+ * dataPolicyServiceSettingsBuilder.build();
+ * }
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class DataPolicyServiceStubSettings extends StubSettings