Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
+ *
+ *
Operation: An Operation represents work being performed in the background.
+ *
+ *
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a
+ * combination of kinds and namespaces (either or both of which may be all).
+ *
+ *
The Export/Import service provides the ability to copy all or a subset of entities to/from
+ * Google Cloud Storage.
+ *
+ *
Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It
+ * is not restricted to the export source project. It is possible to export from one project and
+ * then import into another.
+ *
+ *
Exported data can also be loaded into Google BigQuery for analysis.
+ *
+ *
Exports and imports are performed asynchronously. An Operation resource is created for each
+ * export/import. The state (including any errors encountered) of the export/import may be queried
+ * via the Operation resource.
+ *
+ *
# Index
+ *
+ *
The index service manages Cloud Datastore composite indexes.
+ *
+ *
Index creation and deletion are performed asynchronously. An Operation resource is created for
+ * each such asynchronous operation. The state of the operation (including any errors encountered)
+ * may be queried via the Operation resource.
+ *
+ *
# Operation
+ *
+ *
The Operations collection provides a record of actions performed for the specified project
+ * (including any operations in progress). Operations are not created directly but through calls on
+ * other collections or resources.
+ *
+ *
An operation that is not yet done may be cancelled. The request to cancel is asynchronous and
+ * the operation may continue to run for some time after the request to cancel is made.
+ *
+ *
An operation that is done may be deleted so that it is no longer listed as part of the
+ * Operation collection.
+ *
+ *
ListOperations returns all pending operations, but not completed operations.
+ *
+ *
Operations are created by service DatastoreAdmin, but are accessed via service
+ * google.longrunning.Operations.
+ *
+ *
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:
+ *
+ *
Note: close() needs to be called on the DatastoreAdminClient 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 DatastoreAdminSettings to
+ * create(). For example:
+ *
+ *
Please refer to the GitHub repository's samples for more quickstart code snippets.
+ */
+@Generated("by gapic-generator-java")
+public class DatastoreAdminClient implements BackgroundResource {
+ private final DatastoreAdminSettings settings;
+ private final DatastoreAdminStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of DatastoreAdminClient with default settings. */
+ public static final DatastoreAdminClient create() throws IOException {
+ return create(DatastoreAdminSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of DatastoreAdminClient, 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 DatastoreAdminClient create(DatastoreAdminSettings settings)
+ throws IOException {
+ return new DatastoreAdminClient(settings);
+ }
+
+ /**
+ * Constructs an instance of DatastoreAdminClient, using the given stub for making calls. This is
+ * for advanced usage - prefer using create(DatastoreAdminSettings).
+ */
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public static final DatastoreAdminClient create(DatastoreAdminStub stub) {
+ return new DatastoreAdminClient(stub);
+ }
+
+ /**
+ * Constructs an instance of DatastoreAdminClient, 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 DatastoreAdminClient(DatastoreAdminSettings settings) throws IOException {
+ this.settings = settings;
+ this.stub = ((DatastoreAdminStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ protected DatastoreAdminClient(DatastoreAdminStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final DatastoreAdminSettings getSettings() {
+ return settings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DatastoreAdminStub getStub() {
+ return stub;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage
+ * system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the
+ * export. The export occurs in the background and its progress can be monitored and managed via
+ * the Operation resource that is created. The output of an export may only be used once the
+ * associated operation is done. If an export operation is cancelled before completion it may
+ * leave partial data behind in Google Cloud Storage.
+ *
+ *
+ *
+ * @param projectId Required. Project ID against which to make the request.
+ * @param labels Client-assigned labels.
+ * @param entityFilter Description of what data from the project is included in the export.
+ * @param outputUrlPrefix Required. Location for the export metadata and data files.
+ *
The full resource URL of the external storage location. Currently, only Google Cloud
+ * Storage is supported. So output_url_prefix should be of the form:
+ * `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name of the Cloud Storage
+ * bucket and `NAMESPACE_PATH` is an optional Cloud Storage namespace path (this is not a
+ * Cloud Datastore namespace). For more information about Cloud Storage namespace paths, see
+ * [Object name
+ * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+ *
The resulting files will be nested deeper than the specified URL prefix. The final
+ * output URL will be provided in the
+ * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+ * field. That value should be used for subsequent ImportEntities operations.
+ *
By nesting the data files deeper, the same Cloud Storage bucket can be used in multiple
+ * ExportEntities operations without conflict.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture exportEntitiesAsync(
+ String projectId,
+ Map labels,
+ EntityFilter entityFilter,
+ String outputUrlPrefix) {
+ ExportEntitiesRequest request =
+ ExportEntitiesRequest.newBuilder()
+ .setProjectId(projectId)
+ .putAllLabels(labels)
+ .setEntityFilter(entityFilter)
+ .setOutputUrlPrefix(outputUrlPrefix)
+ .build();
+ return exportEntitiesAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage
+ * system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the
+ * export. The export occurs in the background and its progress can be monitored and managed via
+ * the Operation resource that is created. The output of an export may only be used once the
+ * associated operation is done. If an export operation is cancelled before completion it may
+ * leave partial data behind in Google Cloud Storage.
+ *
+ *
+ *
+ * @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 OperationFuture exportEntitiesAsync(
+ ExportEntitiesRequest request) {
+ return exportEntitiesOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage
+ * system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the
+ * export. The export occurs in the background and its progress can be monitored and managed via
+ * the Operation resource that is created. The output of an export may only be used once the
+ * associated operation is done. If an export operation is cancelled before completion it may
+ * leave partial data behind in Google Cloud Storage.
+ *
+ *
+ */
+ public final OperationCallable<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationCallable() {
+ return stub.exportEntitiesOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage
+ * system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the
+ * export. The export occurs in the background and its progress can be monitored and managed via
+ * the Operation resource that is created. The output of an export may only be used once the
+ * associated operation is done. If an export operation is cancelled before completion it may
+ * leave partial data behind in Google Cloud Storage.
+ *
+ *
+ */
+ public final UnaryCallable exportEntitiesCallable() {
+ return stub.exportEntitiesCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Imports entities into Google Cloud Datastore. Existing entities with the same key are
+ * overwritten. The import occurs in the background and its progress can be monitored and managed
+ * via the Operation resource that is created. If an ImportEntities operation is cancelled, it is
+ * possible that a subset of the data has already been imported to Cloud Datastore.
+ *
+ *
+ *
+ * @param projectId Required. Project ID against which to make the request.
+ * @param labels Client-assigned labels.
+ * @param inputUrl Required. The full resource URL of the external storage location. Currently,
+ * only Google Cloud Storage is supported. So input_url should be of the form:
+ * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where `BUCKET_NAME` is
+ * the name of the Cloud Storage bucket, `NAMESPACE_PATH` is an optional Cloud Storage
+ * namespace path (this is not a Cloud Datastore namespace), and
+ * `OVERALL_EXPORT_METADATA_FILE` is the metadata file written by the ExportEntities
+ * operation. For more information about Cloud Storage namespace paths, see [Object name
+ * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+ *
For more information, see
+ * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+ * @param entityFilter Optionally specify which kinds/namespaces are to be imported. If provided,
+ * the list must be a subset of the EntityFilter used in creating the export, otherwise a
+ * FAILED_PRECONDITION error will be returned. If no filter is specified then all entities
+ * from the export are imported.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture importEntitiesAsync(
+ String projectId, Map labels, String inputUrl, EntityFilter entityFilter) {
+ ImportEntitiesRequest request =
+ ImportEntitiesRequest.newBuilder()
+ .setProjectId(projectId)
+ .putAllLabels(labels)
+ .setInputUrl(inputUrl)
+ .setEntityFilter(entityFilter)
+ .build();
+ return importEntitiesAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Imports entities into Google Cloud Datastore. Existing entities with the same key are
+ * overwritten. The import occurs in the background and its progress can be monitored and managed
+ * via the Operation resource that is created. If an ImportEntities operation is cancelled, it is
+ * possible that a subset of the data has already been imported to Cloud Datastore.
+ *
+ *
+ *
+ * @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 OperationFuture importEntitiesAsync(
+ ImportEntitiesRequest request) {
+ return importEntitiesOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Imports entities into Google Cloud Datastore. Existing entities with the same key are
+ * overwritten. The import occurs in the background and its progress can be monitored and managed
+ * via the Operation resource that is created. If an ImportEntities operation is cancelled, it is
+ * possible that a subset of the data has already been imported to Cloud Datastore.
+ *
+ *
+ */
+ public final OperationCallable
+ importEntitiesOperationCallable() {
+ return stub.importEntitiesOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Imports entities into Google Cloud Datastore. Existing entities with the same key are
+ * overwritten. The import occurs in the background and its progress can be monitored and managed
+ * via the Operation resource that is created. If an ImportEntities operation is cancelled, it is
+ * possible that a subset of the data has already been imported to Cloud Datastore.
+ *
+ *
+ */
+ public final UnaryCallable importEntitiesCallable() {
+ return stub.importEntitiesCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates the specified index. A newly created index's initial state is `CREATING`. On completion
+ * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be
+ * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status.
+ *
+ *
During index creation, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex],
+ * then re-creating the index with [create]
+ * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+ *
+ *
Indexes with a single property cannot be created.
+ *
+ *
+ *
+ * @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 OperationFuture createIndexAsync(
+ CreateIndexRequest request) {
+ return createIndexOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates the specified index. A newly created index's initial state is `CREATING`. On completion
+ * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be
+ * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status.
+ *
+ *
During index creation, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex],
+ * then re-creating the index with [create]
+ * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+ *
+ *
Indexes with a single property cannot be created.
+ *
+ *
+ */
+ public final OperationCallable
+ createIndexOperationCallable() {
+ return stub.createIndexOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates the specified index. A newly created index's initial state is `CREATING`. On completion
+ * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be
+ * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status.
+ *
+ *
During index creation, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex],
+ * then re-creating the index with [create]
+ * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+ *
+ *
Indexes with a single property cannot be created.
+ *
+ *
+ */
+ public final UnaryCallable createIndexCallable() {
+ return stub.createIndexCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state.
+ * On successful execution of the request, the index will be in a `DELETING`
+ * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned
+ * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed.
+ *
+ *
During index deletion, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]
+ * again.
+ *
+ *
+ *
+ * @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 OperationFuture deleteIndexAsync(
+ DeleteIndexRequest request) {
+ return deleteIndexOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state.
+ * On successful execution of the request, the index will be in a `DELETING`
+ * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned
+ * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed.
+ *
+ *
During index deletion, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]
+ * again.
+ *
+ *
+ */
+ public final OperationCallable
+ deleteIndexOperationCallable() {
+ return stub.deleteIndexOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state.
+ * On successful execution of the request, the index will be in a `DELETING`
+ * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned
+ * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed.
+ *
+ *
During index deletion, the process could result in an error, in which case the index will
+ * move to the `ERROR` state. The process can be recovered by fixing the data that caused the
+ * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]
+ * again.
+ *
+ *
+ *
+ * @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 Index getIndex(GetIndexRequest request) {
+ return getIndexCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets an index.
+ *
+ *
+ */
+ public final UnaryCallable getIndexCallable() {
+ return stub.getIndexCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the indexes that match the specified filters. Datastore uses an eventually consistent
+ * query to fetch the list of indexes and may occasionally return stale results.
+ *
+ *
+ *
+ * @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 ListIndexesPagedResponse listIndexes(ListIndexesRequest request) {
+ return listIndexesPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the indexes that match the specified filters. Datastore uses an eventually consistent
+ * query to fetch the list of indexes and may occasionally return stale results.
+ *
+ *
+ */
+ public final UnaryCallable
+ listIndexesPagedCallable() {
+ return stub.listIndexesPagedCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the indexes that match the specified filters. Datastore uses an eventually consistent
+ * query to fetch the list of indexes and may occasionally return stale results.
+ *
+ *
+ */
+ public final UnaryCallable listIndexesCallable() {
+ return stub.listIndexesCallable();
+ }
+
+ @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 ListIndexesPagedResponse
+ extends AbstractPagedListResponse<
+ ListIndexesRequest,
+ ListIndexesResponse,
+ Index,
+ ListIndexesPage,
+ ListIndexesFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListIndexesPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage, input -> new ListIndexesPagedResponse(input), MoreExecutors.directExecutor());
+ }
+
+ private ListIndexesPagedResponse(ListIndexesPage page) {
+ super(page, ListIndexesFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListIndexesPage
+ extends AbstractPage {
+
+ private ListIndexesPage(
+ PageContext context,
+ ListIndexesResponse response) {
+ super(context, response);
+ }
+
+ private static ListIndexesPage createEmptyPage() {
+ return new ListIndexesPage(null, null);
+ }
+
+ @Override
+ protected ListIndexesPage createPage(
+ PageContext context,
+ ListIndexesResponse response) {
+ return new ListIndexesPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListIndexesFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListIndexesRequest,
+ ListIndexesResponse,
+ Index,
+ ListIndexesPage,
+ ListIndexesFixedSizeCollection> {
+
+ private ListIndexesFixedSizeCollection(List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListIndexesFixedSizeCollection createEmptyCollection() {
+ return new ListIndexesFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListIndexesFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListIndexesFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java
new file mode 100644
index 000000000..ebb971f50
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1;
+
+import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.datastore.admin.v1.stub.DatastoreAdminStubSettings;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.ExportEntitiesMetadata;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.ExportEntitiesResponse;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesMetadata;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.IndexOperationMetadata;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link DatastoreAdminClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (datastore.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
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 getIndex to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator-java")
+public class DatastoreAdminSettings extends ClientSettings {
+
+ /** Returns the object with the settings used for calls to exportEntities. */
+ public UnaryCallSettings exportEntitiesSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).exportEntitiesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to exportEntities. */
+ public OperationCallSettings<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).exportEntitiesOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to importEntities. */
+ public UnaryCallSettings importEntitiesSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).importEntitiesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to importEntities. */
+ public OperationCallSettings
+ importEntitiesOperationSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).importEntitiesOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to createIndex. */
+ public UnaryCallSettings createIndexSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).createIndexSettings();
+ }
+
+ /** Returns the object with the settings used for calls to createIndex. */
+ public OperationCallSettings
+ createIndexOperationSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).createIndexOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteIndex. */
+ public UnaryCallSettings deleteIndexSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).deleteIndexSettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteIndex. */
+ public OperationCallSettings
+ deleteIndexOperationSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).deleteIndexOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getIndex. */
+ public UnaryCallSettings getIndexSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).getIndexSettings();
+ }
+
+ /** Returns the object with the settings used for calls to listIndexes. */
+ public PagedCallSettings
+ listIndexesSettings() {
+ return ((DatastoreAdminStubSettings) getStubSettings()).listIndexesSettings();
+ }
+
+ public static final DatastoreAdminSettings create(DatastoreAdminStubSettings stub)
+ throws IOException {
+ return new DatastoreAdminSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return DatastoreAdminStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return DatastoreAdminStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DatastoreAdminStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return DatastoreAdminStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return DatastoreAdminStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return DatastoreAdminStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return DatastoreAdminStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DatastoreAdminSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for DatastoreAdminSettings. */
+ public static class Builder extends ClientSettings.Builder {
+
+ protected Builder() throws IOException {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(DatastoreAdminStubSettings.newBuilder(clientContext));
+ }
+
+ protected Builder(DatastoreAdminSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(DatastoreAdminStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ private static Builder createDefault() {
+ return new Builder(DatastoreAdminStubSettings.newBuilder());
+ }
+
+ public DatastoreAdminStubSettings.Builder getStubSettingsBuilder() {
+ return ((DatastoreAdminStubSettings.Builder) getStubSettings());
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to exportEntities. */
+ public UnaryCallSettings.Builder exportEntitiesSettings() {
+ return getStubSettingsBuilder().exportEntitiesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to exportEntities. */
+ public OperationCallSettings.Builder<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings() {
+ return getStubSettingsBuilder().exportEntitiesOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to importEntities. */
+ public UnaryCallSettings.Builder importEntitiesSettings() {
+ return getStubSettingsBuilder().importEntitiesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to importEntities. */
+ public OperationCallSettings.Builder
+ importEntitiesOperationSettings() {
+ return getStubSettingsBuilder().importEntitiesOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createIndex. */
+ public UnaryCallSettings.Builder createIndexSettings() {
+ return getStubSettingsBuilder().createIndexSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createIndex. */
+ public OperationCallSettings.Builder
+ createIndexOperationSettings() {
+ return getStubSettingsBuilder().createIndexOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteIndex. */
+ public UnaryCallSettings.Builder deleteIndexSettings() {
+ return getStubSettingsBuilder().deleteIndexSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteIndex. */
+ public OperationCallSettings.Builder
+ deleteIndexOperationSettings() {
+ return getStubSettingsBuilder().deleteIndexOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getIndex. */
+ public UnaryCallSettings.Builder getIndexSettings() {
+ return getStubSettingsBuilder().getIndexSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to listIndexes. */
+ public PagedCallSettings.Builder<
+ ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>
+ listIndexesSettings() {
+ return getStubSettingsBuilder().listIndexesSettings();
+ }
+
+ @Override
+ public DatastoreAdminSettings build() throws IOException {
+ return new DatastoreAdminSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json
new file mode 100644
index 000000000..205eb5dcd
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json
@@ -0,0 +1,36 @@
+{
+ "schema": "1.0",
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "java",
+ "protoPackage": "google.datastore.admin.v1",
+ "libraryPackage": "com.google.cloud.datastore.admin.v1",
+ "services": {
+ "DatastoreAdmin": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "DatastoreAdminClient",
+ "rpcs": {
+ "CreateIndex": {
+ "methods": ["createIndexAsync", "createIndexOperationCallable", "createIndexCallable"]
+ },
+ "DeleteIndex": {
+ "methods": ["deleteIndexAsync", "deleteIndexOperationCallable", "deleteIndexCallable"]
+ },
+ "ExportEntities": {
+ "methods": ["exportEntitiesAsync", "exportEntitiesAsync", "exportEntitiesOperationCallable", "exportEntitiesCallable"]
+ },
+ "GetIndex": {
+ "methods": ["getIndex", "getIndexCallable"]
+ },
+ "ImportEntities": {
+ "methods": ["importEntitiesAsync", "importEntitiesAsync", "importEntitiesOperationCallable", "importEntitiesCallable"]
+ },
+ "ListIndexes": {
+ "methods": ["listIndexes", "listIndexesPagedCallable", "listIndexesCallable"]
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.java
new file mode 100644
index 000000000..dd1642f61
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2021 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.
+ */
+
+/**
+ * A client to Cloud Datastore API
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
Project, namespace, kind, and entity as defined in the Google Cloud Datastore API.
+ *
+ *
Operation: An Operation represents work being performed in the background.
+ *
+ *
EntityFilter: Allows specifying a subset of entities in a project. This is specified as a
+ * combination of kinds and namespaces (either or both of which may be all).
+ *
+ *
The Export/Import service provides the ability to copy all or a subset of entities to/from
+ * Google Cloud Storage.
+ *
+ *
Exported data may be imported into Cloud Datastore for any Google Cloud Platform project. It
+ * is not restricted to the export source project. It is possible to export from one project and
+ * then import into another.
+ *
+ *
Exported data can also be loaded into Google BigQuery for analysis.
+ *
+ *
Exports and imports are performed asynchronously. An Operation resource is created for each
+ * export/import. The state (including any errors encountered) of the export/import may be queried
+ * via the Operation resource.
+ *
+ *
# Index
+ *
+ *
The index service manages Cloud Datastore composite indexes.
+ *
+ *
Index creation and deletion are performed asynchronously. An Operation resource is created for
+ * each such asynchronous operation. The state of the operation (including any errors encountered)
+ * may be queried via the Operation resource.
+ *
+ *
# Operation
+ *
+ *
The Operations collection provides a record of actions performed for the specified project
+ * (including any operations in progress). Operations are not created directly but through calls on
+ * other collections or resources.
+ *
+ *
An operation that is not yet done may be cancelled. The request to cancel is asynchronous and
+ * the operation may continue to run for some time after the request to cancel is made.
+ *
+ *
An operation that is done may be deleted so that it is no longer listed as part of the
+ * Operation collection.
+ *
+ *
ListOperations returns all pending operations, but not completed operations.
+ *
+ *
Operations are created by service DatastoreAdmin, but are accessed via service
+ * google.longrunning.Operations.
+ *
+ *
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.datastore.admin.v1;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.java
new file mode 100644
index 000000000..8014b0192
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1.stub;
+
+import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.ExportEntitiesMetadata;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.ExportEntitiesResponse;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesMetadata;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.IndexOperationMetadata;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import com.google.protobuf.Empty;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the DatastoreAdmin service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class DatastoreAdminStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ public OperationCallable
+ exportEntitiesOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: exportEntitiesOperationCallable()");
+ }
+
+ public UnaryCallable exportEntitiesCallable() {
+ throw new UnsupportedOperationException("Not implemented: exportEntitiesCallable()");
+ }
+
+ public OperationCallable
+ importEntitiesOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: importEntitiesOperationCallable()");
+ }
+
+ public UnaryCallable importEntitiesCallable() {
+ throw new UnsupportedOperationException("Not implemented: importEntitiesCallable()");
+ }
+
+ public OperationCallable
+ createIndexOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: createIndexOperationCallable()");
+ }
+
+ public UnaryCallable createIndexCallable() {
+ throw new UnsupportedOperationException("Not implemented: createIndexCallable()");
+ }
+
+ public OperationCallable
+ deleteIndexOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteIndexOperationCallable()");
+ }
+
+ public UnaryCallable deleteIndexCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteIndexCallable()");
+ }
+
+ public UnaryCallable getIndexCallable() {
+ throw new UnsupportedOperationException("Not implemented: getIndexCallable()");
+ }
+
+ public UnaryCallable listIndexesPagedCallable() {
+ throw new UnsupportedOperationException("Not implemented: listIndexesPagedCallable()");
+ }
+
+ public UnaryCallable listIndexesCallable() {
+ throw new UnsupportedOperationException("Not implemented: listIndexesCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java
new file mode 100644
index 000000000..682fe82f3
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java
@@ -0,0 +1,670 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1.stub;
+
+import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.ApiFuture;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.GrpcTransportChannel;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.grpc.ProtoOperationTransformers;
+import com.google.api.gax.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiCallContext;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.PagedListDescriptor;
+import com.google.api.gax.rpc.PagedListResponseFactory;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.ExportEntitiesMetadata;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.ExportEntitiesResponse;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesMetadata;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.IndexOperationMetadata;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link DatastoreAdminStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (datastore.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
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 getIndex to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator-java")
+public class DatastoreAdminStubSettings extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder()
+ .add("https://www.googleapis.com/auth/cloud-platform")
+ .add("https://www.googleapis.com/auth/datastore")
+ .build();
+
+ private final UnaryCallSettings exportEntitiesSettings;
+ private final OperationCallSettings<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings;
+ private final UnaryCallSettings importEntitiesSettings;
+ private final OperationCallSettings
+ importEntitiesOperationSettings;
+ private final UnaryCallSettings createIndexSettings;
+ private final OperationCallSettings
+ createIndexOperationSettings;
+ private final UnaryCallSettings deleteIndexSettings;
+ private final OperationCallSettings
+ deleteIndexOperationSettings;
+ private final UnaryCallSettings getIndexSettings;
+ private final PagedCallSettings
+ listIndexesSettings;
+
+ private static final PagedListDescriptor
+ LIST_INDEXES_PAGE_STR_DESC =
+ new PagedListDescriptor() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListIndexesRequest injectToken(ListIndexesRequest payload, String token) {
+ return ListIndexesRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListIndexesRequest injectPageSize(ListIndexesRequest payload, int pageSize) {
+ return ListIndexesRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListIndexesRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListIndexesResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(ListIndexesResponse payload) {
+ return payload.getIndexesList() == null
+ ? ImmutableList.of()
+ : payload.getIndexesList();
+ }
+ };
+
+ private static final PagedListResponseFactory<
+ ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>
+ LIST_INDEXES_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListIndexesRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext pageContext =
+ PageContext.create(callable, LIST_INDEXES_PAGE_STR_DESC, request, context);
+ return ListIndexesPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
+ /** Returns the object with the settings used for calls to exportEntities. */
+ public UnaryCallSettings exportEntitiesSettings() {
+ return exportEntitiesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to exportEntities. */
+ public OperationCallSettings<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings() {
+ return exportEntitiesOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to importEntities. */
+ public UnaryCallSettings importEntitiesSettings() {
+ return importEntitiesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to importEntities. */
+ public OperationCallSettings
+ importEntitiesOperationSettings() {
+ return importEntitiesOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to createIndex. */
+ public UnaryCallSettings createIndexSettings() {
+ return createIndexSettings;
+ }
+
+ /** Returns the object with the settings used for calls to createIndex. */
+ public OperationCallSettings
+ createIndexOperationSettings() {
+ return createIndexOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteIndex. */
+ public UnaryCallSettings deleteIndexSettings() {
+ return deleteIndexSettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteIndex. */
+ public OperationCallSettings
+ deleteIndexOperationSettings() {
+ return deleteIndexOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getIndex. */
+ public UnaryCallSettings getIndexSettings() {
+ return getIndexSettings;
+ }
+
+ /** Returns the object with the settings used for calls to listIndexes. */
+ public PagedCallSettings
+ listIndexesSettings() {
+ return listIndexesSettings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public DatastoreAdminStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcDatastoreAdminStub.create(this);
+ }
+ throw new UnsupportedOperationException(
+ String.format(
+ "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "datastore.googleapis.com:443";
+ }
+
+ /** Returns the default mTLS service endpoint. */
+ public static String getDefaultMtlsEndpoint() {
+ return "datastore.mtls.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder()
+ .setScopesToApply(DEFAULT_SERVICE_SCOPES)
+ .setUseJwtAccessWithScope(true);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return defaultGrpcTransportProviderBuilder().build();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(DatastoreAdminStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected DatastoreAdminStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ exportEntitiesSettings = settingsBuilder.exportEntitiesSettings().build();
+ exportEntitiesOperationSettings = settingsBuilder.exportEntitiesOperationSettings().build();
+ importEntitiesSettings = settingsBuilder.importEntitiesSettings().build();
+ importEntitiesOperationSettings = settingsBuilder.importEntitiesOperationSettings().build();
+ createIndexSettings = settingsBuilder.createIndexSettings().build();
+ createIndexOperationSettings = settingsBuilder.createIndexOperationSettings().build();
+ deleteIndexSettings = settingsBuilder.deleteIndexSettings().build();
+ deleteIndexOperationSettings = settingsBuilder.deleteIndexOperationSettings().build();
+ getIndexSettings = settingsBuilder.getIndexSettings().build();
+ listIndexesSettings = settingsBuilder.listIndexesSettings().build();
+ }
+
+ /** Builder for DatastoreAdminStubSettings. */
+ public static class Builder extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+ private final UnaryCallSettings.Builder
+ exportEntitiesSettings;
+ private final OperationCallSettings.Builder<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings;
+ private final UnaryCallSettings.Builder
+ importEntitiesSettings;
+ private final OperationCallSettings.Builder<
+ ImportEntitiesRequest, Empty, ImportEntitiesMetadata>
+ importEntitiesOperationSettings;
+ private final UnaryCallSettings.Builder createIndexSettings;
+ private final OperationCallSettings.Builder
+ createIndexOperationSettings;
+ private final UnaryCallSettings.Builder deleteIndexSettings;
+ private final OperationCallSettings.Builder
+ deleteIndexOperationSettings;
+ private final UnaryCallSettings.Builder getIndexSettings;
+ private final PagedCallSettings.Builder<
+ ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>
+ listIndexesSettings;
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList()));
+ definitions.put(
+ "retry_policy_1_codes",
+ ImmutableSet.copyOf(
+ Lists.newArrayList(
+ StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED)));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRpcTimeout(Duration.ofMillis(60000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(60000L))
+ .setTotalTimeout(Duration.ofMillis(60000L))
+ .build();
+ definitions.put("no_retry_0_params", settings);
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(100L))
+ .setRetryDelayMultiplier(1.3)
+ .setMaxRetryDelay(Duration.ofMillis(60000L))
+ .setInitialRpcTimeout(Duration.ofMillis(60000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(60000L))
+ .setTotalTimeout(Duration.ofMillis(60000L))
+ .build();
+ definitions.put("retry_policy_1_params", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ exportEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ exportEntitiesOperationSettings = OperationCallSettings.newBuilder();
+ importEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ importEntitiesOperationSettings = OperationCallSettings.newBuilder();
+ createIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createIndexOperationSettings = OperationCallSettings.newBuilder();
+ deleteIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ deleteIndexOperationSettings = OperationCallSettings.newBuilder();
+ getIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ listIndexesSettings = PagedCallSettings.newBuilder(LIST_INDEXES_PAGE_STR_FACT);
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ exportEntitiesSettings,
+ importEntitiesSettings,
+ createIndexSettings,
+ deleteIndexSettings,
+ getIndexSettings,
+ listIndexesSettings);
+ initDefaults(this);
+ }
+
+ protected Builder(DatastoreAdminStubSettings settings) {
+ super(settings);
+
+ exportEntitiesSettings = settings.exportEntitiesSettings.toBuilder();
+ exportEntitiesOperationSettings = settings.exportEntitiesOperationSettings.toBuilder();
+ importEntitiesSettings = settings.importEntitiesSettings.toBuilder();
+ importEntitiesOperationSettings = settings.importEntitiesOperationSettings.toBuilder();
+ createIndexSettings = settings.createIndexSettings.toBuilder();
+ createIndexOperationSettings = settings.createIndexOperationSettings.toBuilder();
+ deleteIndexSettings = settings.deleteIndexSettings.toBuilder();
+ deleteIndexOperationSettings = settings.deleteIndexOperationSettings.toBuilder();
+ getIndexSettings = settings.getIndexSettings.toBuilder();
+ listIndexesSettings = settings.listIndexesSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ exportEntitiesSettings,
+ importEntitiesSettings,
+ createIndexSettings,
+ deleteIndexSettings,
+ getIndexSettings,
+ listIndexesSettings);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+ builder
+ .exportEntitiesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
+
+ builder
+ .importEntitiesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
+
+ builder
+ .createIndexSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
+
+ builder
+ .deleteIndexSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));
+
+ builder
+ .getIndexSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
+
+ builder
+ .listIndexesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
+
+ builder
+ .exportEntitiesOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(ExportEntitiesResponse.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(ExportEntitiesMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ builder
+ .importEntitiesOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(ImportEntitiesMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ builder
+ .createIndexOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings.newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Index.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(IndexOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ builder
+ .deleteIndexOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings.newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Index.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(IndexOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ return builder;
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to exportEntities. */
+ public UnaryCallSettings.Builder exportEntitiesSettings() {
+ return exportEntitiesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to exportEntities. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationSettings() {
+ return exportEntitiesOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to importEntities. */
+ public UnaryCallSettings.Builder importEntitiesSettings() {
+ return importEntitiesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to importEntities. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ importEntitiesOperationSettings() {
+ return importEntitiesOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createIndex. */
+ public UnaryCallSettings.Builder createIndexSettings() {
+ return createIndexSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createIndex. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ createIndexOperationSettings() {
+ return createIndexOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteIndex. */
+ public UnaryCallSettings.Builder deleteIndexSettings() {
+ return deleteIndexSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteIndex. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ deleteIndexOperationSettings() {
+ return deleteIndexOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getIndex. */
+ public UnaryCallSettings.Builder getIndexSettings() {
+ return getIndexSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to listIndexes. */
+ public PagedCallSettings.Builder<
+ ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse>
+ listIndexesSettings() {
+ return listIndexesSettings;
+ }
+
+ @Override
+ public DatastoreAdminStubSettings build() throws IOException {
+ return new DatastoreAdminStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.java
new file mode 100644
index 000000000..6fa63fd35
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1.stub;
+
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the DatastoreAdmin service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcDatastoreAdminCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, callSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java
new file mode 100644
index 000000000..81e35b3a0
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1.stub;
+
+import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.common.collect.ImmutableMap;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.ExportEntitiesMetadata;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.ExportEntitiesResponse;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesMetadata;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.IndexOperationMetadata;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import com.google.protobuf.Empty;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC stub implementation for the DatastoreAdmin service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcDatastoreAdminStub extends DatastoreAdminStub {
+ private static final MethodDescriptor
+ exportEntitiesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ExportEntities")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ExportEntitiesRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ importEntitiesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ImportEntities")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ImportEntitiesRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor createIndexMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/CreateIndex")
+ .setRequestMarshaller(ProtoUtils.marshaller(CreateIndexRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor deleteIndexMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/DeleteIndex")
+ .setRequestMarshaller(ProtoUtils.marshaller(DeleteIndexRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor getIndexMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/GetIndex")
+ .setRequestMarshaller(ProtoUtils.marshaller(GetIndexRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Index.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ listIndexesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ListIndexes")
+ .setRequestMarshaller(ProtoUtils.marshaller(ListIndexesRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListIndexesResponse.getDefaultInstance()))
+ .build();
+
+ private final UnaryCallable exportEntitiesCallable;
+ private final OperationCallable<
+ ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata>
+ exportEntitiesOperationCallable;
+ private final UnaryCallable importEntitiesCallable;
+ private final OperationCallable
+ importEntitiesOperationCallable;
+ private final UnaryCallable createIndexCallable;
+ private final OperationCallable
+ createIndexOperationCallable;
+ private final UnaryCallable deleteIndexCallable;
+ private final OperationCallable
+ deleteIndexOperationCallable;
+ private final UnaryCallable getIndexCallable;
+ private final UnaryCallable listIndexesCallable;
+ private final UnaryCallable
+ listIndexesPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcDatastoreAdminStub create(DatastoreAdminStubSettings settings)
+ throws IOException {
+ return new GrpcDatastoreAdminStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcDatastoreAdminStub create(ClientContext clientContext)
+ throws IOException {
+ return new GrpcDatastoreAdminStub(
+ DatastoreAdminStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcDatastoreAdminStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcDatastoreAdminStub(
+ DatastoreAdminStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcDatastoreAdminStub, 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 GrpcDatastoreAdminStub(DatastoreAdminStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcDatastoreAdminCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcDatastoreAdminStub, 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 GrpcDatastoreAdminStub(
+ DatastoreAdminStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings exportEntitiesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(exportEntitiesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings importEntitiesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(importEntitiesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings createIndexTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createIndexMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings deleteIndexTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(deleteIndexMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("index_id", String.valueOf(request.getIndexId()));
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings getIndexTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getIndexMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("index_id", String.valueOf(request.getIndexId()));
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings listIndexesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(listIndexesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("project_id", String.valueOf(request.getProjectId()));
+ return params.build();
+ })
+ .build();
+
+ this.exportEntitiesCallable =
+ callableFactory.createUnaryCallable(
+ exportEntitiesTransportSettings, settings.exportEntitiesSettings(), clientContext);
+ this.exportEntitiesOperationCallable =
+ callableFactory.createOperationCallable(
+ exportEntitiesTransportSettings,
+ settings.exportEntitiesOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.importEntitiesCallable =
+ callableFactory.createUnaryCallable(
+ importEntitiesTransportSettings, settings.importEntitiesSettings(), clientContext);
+ this.importEntitiesOperationCallable =
+ callableFactory.createOperationCallable(
+ importEntitiesTransportSettings,
+ settings.importEntitiesOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.createIndexCallable =
+ callableFactory.createUnaryCallable(
+ createIndexTransportSettings, settings.createIndexSettings(), clientContext);
+ this.createIndexOperationCallable =
+ callableFactory.createOperationCallable(
+ createIndexTransportSettings,
+ settings.createIndexOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.deleteIndexCallable =
+ callableFactory.createUnaryCallable(
+ deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext);
+ this.deleteIndexOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteIndexTransportSettings,
+ settings.deleteIndexOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.getIndexCallable =
+ callableFactory.createUnaryCallable(
+ getIndexTransportSettings, settings.getIndexSettings(), clientContext);
+ this.listIndexesCallable =
+ callableFactory.createUnaryCallable(
+ listIndexesTransportSettings, settings.listIndexesSettings(), clientContext);
+ this.listIndexesPagedCallable =
+ callableFactory.createPagedCallable(
+ listIndexesTransportSettings, settings.listIndexesSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @Override
+ public UnaryCallable exportEntitiesCallable() {
+ return exportEntitiesCallable;
+ }
+
+ @Override
+ public OperationCallable
+ exportEntitiesOperationCallable() {
+ return exportEntitiesOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable importEntitiesCallable() {
+ return importEntitiesCallable;
+ }
+
+ @Override
+ public OperationCallable
+ importEntitiesOperationCallable() {
+ return importEntitiesOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable createIndexCallable() {
+ return createIndexCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createIndexOperationCallable() {
+ return createIndexOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteIndexCallable() {
+ return deleteIndexCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteIndexOperationCallable() {
+ return deleteIndexOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getIndexCallable() {
+ return getIndexCallable;
+ }
+
+ @Override
+ public UnaryCallable listIndexesCallable() {
+ return listIndexesCallable;
+ }
+
+ @Override
+ public UnaryCallable listIndexesPagedCallable() {
+ return listIndexesPagedCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java
new file mode 100644
index 000000000..577037ec4
--- /dev/null
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java
@@ -0,0 +1,428 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1;
+
+import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.ListIndexesPagedResponse;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.testing.LocalChannelProvider;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.api.gax.grpc.testing.MockServiceHelper;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.common.collect.Lists;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.EntityFilter;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.ExportEntitiesResponse;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import com.google.protobuf.Any;
+import com.google.protobuf.Empty;
+import io.grpc.StatusRuntimeException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import javax.annotation.Generated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Generated("by gapic-generator-java")
+public class DatastoreAdminClientTest {
+ private static MockDatastoreAdmin mockDatastoreAdmin;
+ private static MockServiceHelper mockServiceHelper;
+ private LocalChannelProvider channelProvider;
+ private DatastoreAdminClient client;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockDatastoreAdmin = new MockDatastoreAdmin();
+ mockServiceHelper =
+ new MockServiceHelper(
+ UUID.randomUUID().toString(), Arrays.asList(mockDatastoreAdmin));
+ mockServiceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ mockServiceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ mockServiceHelper.reset();
+ channelProvider = mockServiceHelper.createChannelProvider();
+ DatastoreAdminSettings settings =
+ DatastoreAdminSettings.newBuilder()
+ .setTransportChannelProvider(channelProvider)
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = DatastoreAdminClient.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ client.close();
+ }
+
+ @Test
+ public void exportEntitiesTest() throws Exception {
+ ExportEntitiesResponse expectedResponse =
+ ExportEntitiesResponse.newBuilder().setOutputUrl("outputUrl-2119300946").build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("exportEntitiesTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockDatastoreAdmin.addResponse(resultOperation);
+
+ String projectId = "projectId-894832108";
+ Map labels = new HashMap<>();
+ EntityFilter entityFilter = EntityFilter.newBuilder().build();
+ String outputUrlPrefix = "outputUrlPrefix-1132598048";
+
+ ExportEntitiesResponse actualResponse =
+ client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ExportEntitiesRequest actualRequest = ((ExportEntitiesRequest) actualRequests.get(0));
+
+ Assert.assertEquals(projectId, actualRequest.getProjectId());
+ Assert.assertEquals(labels, actualRequest.getLabelsMap());
+ Assert.assertEquals(entityFilter, actualRequest.getEntityFilter());
+ Assert.assertEquals(outputUrlPrefix, actualRequest.getOutputUrlPrefix());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void exportEntitiesExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ String projectId = "projectId-894832108";
+ Map labels = new HashMap<>();
+ EntityFilter entityFilter = EntityFilter.newBuilder().build();
+ String outputUrlPrefix = "outputUrlPrefix-1132598048";
+ client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void importEntitiesTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("importEntitiesTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockDatastoreAdmin.addResponse(resultOperation);
+
+ String projectId = "projectId-894832108";
+ Map labels = new HashMap<>();
+ String inputUrl = "inputUrl470706501";
+ EntityFilter entityFilter = EntityFilter.newBuilder().build();
+
+ client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get();
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ImportEntitiesRequest actualRequest = ((ImportEntitiesRequest) actualRequests.get(0));
+
+ Assert.assertEquals(projectId, actualRequest.getProjectId());
+ Assert.assertEquals(labels, actualRequest.getLabelsMap());
+ Assert.assertEquals(inputUrl, actualRequest.getInputUrl());
+ Assert.assertEquals(entityFilter, actualRequest.getEntityFilter());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void importEntitiesExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ String projectId = "projectId-894832108";
+ Map labels = new HashMap<>();
+ String inputUrl = "inputUrl470706501";
+ EntityFilter entityFilter = EntityFilter.newBuilder().build();
+ client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void createIndexTest() throws Exception {
+ Index expectedResponse =
+ Index.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .setKind("kind3292052")
+ .addAllProperties(new ArrayList())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createIndexTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockDatastoreAdmin.addResponse(resultOperation);
+
+ CreateIndexRequest request =
+ CreateIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndex(Index.newBuilder().build())
+ .build();
+
+ Index actualResponse = client.createIndexAsync(request).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0));
+
+ Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
+ Assert.assertEquals(request.getIndex(), actualRequest.getIndex());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void createIndexExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ CreateIndexRequest request =
+ CreateIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndex(Index.newBuilder().build())
+ .build();
+ client.createIndexAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void deleteIndexTest() throws Exception {
+ Index expectedResponse =
+ Index.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .setKind("kind3292052")
+ .addAllProperties(new ArrayList())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("deleteIndexTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockDatastoreAdmin.addResponse(resultOperation);
+
+ DeleteIndexRequest request =
+ DeleteIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .build();
+
+ Index actualResponse = client.deleteIndexAsync(request).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0));
+
+ Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
+ Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void deleteIndexExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ DeleteIndexRequest request =
+ DeleteIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .build();
+ client.deleteIndexAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void getIndexTest() throws Exception {
+ Index expectedResponse =
+ Index.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .setKind("kind3292052")
+ .addAllProperties(new ArrayList())
+ .build();
+ mockDatastoreAdmin.addResponse(expectedResponse);
+
+ GetIndexRequest request =
+ GetIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .build();
+
+ Index actualResponse = client.getIndex(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
+
+ Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
+ Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void getIndexExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ GetIndexRequest request =
+ GetIndexRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setIndexId("indexId1943291277")
+ .build();
+ client.getIndex(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listIndexesTest() throws Exception {
+ Index responsesElement = Index.newBuilder().build();
+ ListIndexesResponse expectedResponse =
+ ListIndexesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllIndexes(Arrays.asList(responsesElement))
+ .build();
+ mockDatastoreAdmin.addResponse(expectedResponse);
+
+ ListIndexesRequest request =
+ ListIndexesRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setFilter("filter-1274492040")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .build();
+
+ ListIndexesPagedResponse pagedListResponse = client.listIndexes(request);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
+
+ List actualRequests = mockDatastoreAdmin.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
+
+ Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
+ Assert.assertEquals(request.getFilter(), actualRequest.getFilter());
+ Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
+ Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void listIndexesExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockDatastoreAdmin.addException(exception);
+
+ try {
+ ListIndexesRequest request =
+ ListIndexesRequest.newBuilder()
+ .setProjectId("projectId-894832108")
+ .setFilter("filter-1274492040")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .build();
+ client.listIndexes(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.java
new file mode 100644
index 000000000..ee0a0961b
--- /dev/null
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockDatastoreAdmin implements MockGrpcService {
+ private final MockDatastoreAdminImpl serviceImpl;
+
+ public MockDatastoreAdmin() {
+ serviceImpl = new MockDatastoreAdminImpl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void addResponse(AbstractMessage response) {
+ serviceImpl.addResponse(response);
+ }
+
+ @Override
+ public void addException(Exception exception) {
+ serviceImpl.addException(exception);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.java
new file mode 100644
index 000000000..9536e69e2
--- /dev/null
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2021 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.datastore.admin.v1;
+
+import com.google.api.core.BetaApi;
+import com.google.datastore.admin.v1.CreateIndexRequest;
+import com.google.datastore.admin.v1.DatastoreAdminGrpc.DatastoreAdminImplBase;
+import com.google.datastore.admin.v1.DeleteIndexRequest;
+import com.google.datastore.admin.v1.ExportEntitiesRequest;
+import com.google.datastore.admin.v1.GetIndexRequest;
+import com.google.datastore.admin.v1.ImportEntitiesRequest;
+import com.google.datastore.admin.v1.Index;
+import com.google.datastore.admin.v1.ListIndexesRequest;
+import com.google.datastore.admin.v1.ListIndexesResponse;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockDatastoreAdminImpl extends DatastoreAdminImplBase {
+ private List requests;
+ private Queue