+ beginTransactionCallable() {
+ return stub.beginTransactionCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Commits a transaction, optionally creating, deleting or modifying some entities.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0);
+ * List mutations = new ArrayList<>();
+ * CommitResponse response = datastoreClient.commit(projectId, mode, mutations);
+ * }
+ * }
+ *
+ * @param projectId Required. The ID of the project against which to make the request.
+ * @param mode The type of commit to perform. Defaults to `TRANSACTIONAL`.
+ * @param mutations The mutations to perform.
+ * When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order.
+ * The following sequences of mutations affecting a single entity are not permitted in a
+ * single `Commit` request:
+ *
- `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by
+ * `insert` - `delete` followed by `update`
+ *
When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CommitResponse commit(
+ String projectId, CommitRequest.Mode mode, List mutations) {
+ CommitRequest request =
+ CommitRequest.newBuilder()
+ .setProjectId(projectId)
+ .setMode(mode)
+ .addAllMutations(mutations)
+ .build();
+ return commit(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Commits a transaction, optionally creating, deleting or modifying some entities.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0);
+ * ByteString transaction = ByteString.EMPTY;
+ * List mutations = new ArrayList<>();
+ * CommitResponse response = datastoreClient.commit(projectId, mode, transaction, mutations);
+ * }
+ * }
+ *
+ * @param projectId Required. The ID of the project against which to make the request.
+ * @param mode The type of commit to perform. Defaults to `TRANSACTIONAL`.
+ * @param transaction The identifier of the transaction associated with the commit. A transaction
+ * identifier is returned by a call to
+ * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+ * @param mutations The mutations to perform.
+ * When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order.
+ * The following sequences of mutations affecting a single entity are not permitted in a
+ * single `Commit` request:
+ *
- `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by
+ * `insert` - `delete` followed by `update`
+ *
When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CommitResponse commit(
+ String projectId, CommitRequest.Mode mode, ByteString transaction, List mutations) {
+ CommitRequest request =
+ CommitRequest.newBuilder()
+ .setProjectId(projectId)
+ .setMode(mode)
+ .setTransaction(transaction)
+ .addAllMutations(mutations)
+ .build();
+ return commit(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Commits a transaction, optionally creating, deleting or modifying some entities.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * CommitRequest request =
+ * CommitRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllMutations(new ArrayList())
+ * .build();
+ * CommitResponse response = datastoreClient.commit(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CommitResponse commit(CommitRequest request) {
+ return commitCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Commits a transaction, optionally creating, deleting or modifying some entities.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * CommitRequest request =
+ * CommitRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllMutations(new ArrayList())
+ * .build();
+ * ApiFuture future = datastoreClient.commitCallable().futureCall(request);
+ * // Do something.
+ * CommitResponse response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable commitCallable() {
+ return stub.commitCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Rolls back a transaction.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * ByteString transaction = ByteString.EMPTY;
+ * RollbackResponse response = datastoreClient.rollback(projectId, transaction);
+ * }
+ * }
+ *
+ * @param projectId Required. The ID of the project against which to make the request.
+ * @param transaction Required. The transaction identifier, returned by a call to
+ * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final RollbackResponse rollback(String projectId, ByteString transaction) {
+ RollbackRequest request =
+ RollbackRequest.newBuilder().setProjectId(projectId).setTransaction(transaction).build();
+ return rollback(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Rolls back a transaction.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * RollbackRequest request =
+ * RollbackRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .setTransaction(ByteString.EMPTY)
+ * .build();
+ * RollbackResponse response = datastoreClient.rollback(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final RollbackResponse rollback(RollbackRequest request) {
+ return rollbackCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Rolls back a transaction.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * RollbackRequest request =
+ * RollbackRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .setTransaction(ByteString.EMPTY)
+ * .build();
+ * ApiFuture future = datastoreClient.rollbackCallable().futureCall(request);
+ * // Do something.
+ * RollbackResponse response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable rollbackCallable() {
+ return stub.rollbackCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Allocates IDs for the given keys, which is useful for referencing an entity before it is
+ * inserted.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * List keys = new ArrayList<>();
+ * AllocateIdsResponse response = datastoreClient.allocateIds(projectId, keys);
+ * }
+ * }
+ *
+ * @param projectId Required. The ID of the project against which to make the request.
+ * @param keys Required. A list of keys with incomplete key paths for which to allocate IDs. No
+ * key may be reserved/read-only.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final AllocateIdsResponse allocateIds(String projectId, List keys) {
+ AllocateIdsRequest request =
+ AllocateIdsRequest.newBuilder().setProjectId(projectId).addAllKeys(keys).build();
+ return allocateIds(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Allocates IDs for the given keys, which is useful for referencing an entity before it is
+ * inserted.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * AllocateIdsRequest request =
+ * AllocateIdsRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllKeys(new ArrayList())
+ * .build();
+ * AllocateIdsResponse response = datastoreClient.allocateIds(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final AllocateIdsResponse allocateIds(AllocateIdsRequest request) {
+ return allocateIdsCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Allocates IDs for the given keys, which is useful for referencing an entity before it is
+ * inserted.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * AllocateIdsRequest request =
+ * AllocateIdsRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllKeys(new ArrayList())
+ * .build();
+ * ApiFuture future =
+ * datastoreClient.allocateIdsCallable().futureCall(request);
+ * // Do something.
+ * AllocateIdsResponse response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable allocateIdsCallable() {
+ return stub.allocateIdsCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * List keys = new ArrayList<>();
+ * ReserveIdsResponse response = datastoreClient.reserveIds(projectId, keys);
+ * }
+ * }
+ *
+ * @param projectId Required. The ID of the project against which to make the request.
+ * @param keys Required. A list of keys with complete key paths whose numeric IDs should not be
+ * auto-allocated.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ReserveIdsResponse reserveIds(String projectId, List keys) {
+ ReserveIdsRequest request =
+ ReserveIdsRequest.newBuilder().setProjectId(projectId).addAllKeys(keys).build();
+ return reserveIds(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * ReserveIdsRequest request =
+ * ReserveIdsRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllKeys(new ArrayList())
+ * .build();
+ * ReserveIdsResponse response = datastoreClient.reserveIds(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ReserveIdsResponse reserveIds(ReserveIdsRequest request) {
+ return reserveIdsCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * ReserveIdsRequest request =
+ * ReserveIdsRequest.newBuilder()
+ * .setProjectId("projectId-894832108")
+ * .setDatabaseId("databaseId1688905718")
+ * .addAllKeys(new ArrayList())
+ * .build();
+ * ApiFuture future =
+ * datastoreClient.reserveIdsCallable().futureCall(request);
+ * // Do something.
+ * ReserveIdsResponse response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable reserveIdsCallable() {
+ return stub.reserveIdsCallable();
+ }
+
+ @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);
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java
new file mode 100644
index 000000000..22feacdce
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1;
+
+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.httpjson.InstantiatingHttpJsonChannelProvider;
+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.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.datastore.v1.stub.DatastoreStubSettings;
+import com.google.datastore.v1.AllocateIdsRequest;
+import com.google.datastore.v1.AllocateIdsResponse;
+import com.google.datastore.v1.BeginTransactionRequest;
+import com.google.datastore.v1.BeginTransactionResponse;
+import com.google.datastore.v1.CommitRequest;
+import com.google.datastore.v1.CommitResponse;
+import com.google.datastore.v1.LookupRequest;
+import com.google.datastore.v1.LookupResponse;
+import com.google.datastore.v1.ReserveIdsRequest;
+import com.google.datastore.v1.ReserveIdsResponse;
+import com.google.datastore.v1.RollbackRequest;
+import com.google.datastore.v1.RollbackResponse;
+import com.google.datastore.v1.RunAggregationQueryRequest;
+import com.google.datastore.v1.RunAggregationQueryResponse;
+import com.google.datastore.v1.RunQueryRequest;
+import com.google.datastore.v1.RunQueryResponse;
+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 DatastoreClient}.
+ *
+ * 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 lookup to 30 seconds:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreSettings.Builder datastoreSettingsBuilder = DatastoreSettings.newBuilder();
+ * datastoreSettingsBuilder
+ * .lookupSettings()
+ * .setRetrySettings(
+ * datastoreSettingsBuilder
+ * .lookupSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * DatastoreSettings datastoreSettings = datastoreSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class DatastoreSettings extends ClientSettings {
+
+ /** Returns the object with the settings used for calls to lookup. */
+ public UnaryCallSettings lookupSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).lookupSettings();
+ }
+
+ /** Returns the object with the settings used for calls to runQuery. */
+ public UnaryCallSettings runQuerySettings() {
+ return ((DatastoreStubSettings) getStubSettings()).runQuerySettings();
+ }
+
+ /** Returns the object with the settings used for calls to runAggregationQuery. */
+ public UnaryCallSettings
+ runAggregationQuerySettings() {
+ return ((DatastoreStubSettings) getStubSettings()).runAggregationQuerySettings();
+ }
+
+ /** Returns the object with the settings used for calls to beginTransaction. */
+ public UnaryCallSettings
+ beginTransactionSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).beginTransactionSettings();
+ }
+
+ /** Returns the object with the settings used for calls to commit. */
+ public UnaryCallSettings commitSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).commitSettings();
+ }
+
+ /** Returns the object with the settings used for calls to rollback. */
+ public UnaryCallSettings rollbackSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).rollbackSettings();
+ }
+
+ /** Returns the object with the settings used for calls to allocateIds. */
+ public UnaryCallSettings allocateIdsSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).allocateIdsSettings();
+ }
+
+ /** Returns the object with the settings used for calls to reserveIds. */
+ public UnaryCallSettings reserveIdsSettings() {
+ return ((DatastoreStubSettings) getStubSettings()).reserveIdsSettings();
+ }
+
+ public static final DatastoreSettings create(DatastoreStubSettings stub) throws IOException {
+ return new DatastoreSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return DatastoreStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return DatastoreStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DatastoreStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return DatastoreStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return DatastoreStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return DatastoreStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return DatastoreStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return DatastoreStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
+ /** 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 DatastoreSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for DatastoreSettings. */
+ public static class Builder extends ClientSettings.Builder {
+
+ protected Builder() throws IOException {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(DatastoreStubSettings.newBuilder(clientContext));
+ }
+
+ protected Builder(DatastoreSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(DatastoreStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ private static Builder createDefault() {
+ return new Builder(DatastoreStubSettings.newBuilder());
+ }
+
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(DatastoreStubSettings.newHttpJsonBuilder());
+ }
+
+ public DatastoreStubSettings.Builder getStubSettingsBuilder() {
+ return ((DatastoreStubSettings.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 lookup. */
+ public UnaryCallSettings.Builder lookupSettings() {
+ return getStubSettingsBuilder().lookupSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to runQuery. */
+ public UnaryCallSettings.Builder runQuerySettings() {
+ return getStubSettingsBuilder().runQuerySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to runAggregationQuery. */
+ public UnaryCallSettings.Builder
+ runAggregationQuerySettings() {
+ return getStubSettingsBuilder().runAggregationQuerySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to beginTransaction. */
+ public UnaryCallSettings.Builder
+ beginTransactionSettings() {
+ return getStubSettingsBuilder().beginTransactionSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to commit. */
+ public UnaryCallSettings.Builder commitSettings() {
+ return getStubSettingsBuilder().commitSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to rollback. */
+ public UnaryCallSettings.Builder rollbackSettings() {
+ return getStubSettingsBuilder().rollbackSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to allocateIds. */
+ public UnaryCallSettings.Builder
+ allocateIdsSettings() {
+ return getStubSettingsBuilder().allocateIdsSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to reserveIds. */
+ public UnaryCallSettings.Builder reserveIdsSettings() {
+ return getStubSettingsBuilder().reserveIdsSettings();
+ }
+
+ @Override
+ public DatastoreSettings build() throws IOException {
+ return new DatastoreSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json
new file mode 100644
index 000000000..02196d36e
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json
@@ -0,0 +1,42 @@
+{
+ "schema": "1.0",
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "java",
+ "protoPackage": "google.datastore.v1",
+ "libraryPackage": "com.google.cloud.datastore.v1",
+ "services": {
+ "Datastore": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "DatastoreClient",
+ "rpcs": {
+ "AllocateIds": {
+ "methods": ["allocateIds", "allocateIds", "allocateIdsCallable"]
+ },
+ "BeginTransaction": {
+ "methods": ["beginTransaction", "beginTransaction", "beginTransactionCallable"]
+ },
+ "Commit": {
+ "methods": ["commit", "commit", "commit", "commitCallable"]
+ },
+ "Lookup": {
+ "methods": ["lookup", "lookup", "lookupCallable"]
+ },
+ "ReserveIds": {
+ "methods": ["reserveIds", "reserveIds", "reserveIdsCallable"]
+ },
+ "Rollback": {
+ "methods": ["rollback", "rollback", "rollbackCallable"]
+ },
+ "RunAggregationQuery": {
+ "methods": ["runAggregationQuery", "runAggregationQueryCallable"]
+ },
+ "RunQuery": {
+ "methods": ["runQuery", "runQueryCallable"]
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java
new file mode 100644
index 000000000..2227971ca
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A client to Cloud Datastore API
+ *
+ * The interfaces provided are listed below, along with usage samples.
+ *
+ *
======================= DatastoreClient =======================
+ *
+ *
Service Description: Each RPC normalizes the partition IDs of the keys in its input entities,
+ * and always returns entities with keys with normalized partition IDs. This applies to all keys and
+ * entities, including those in values, except keys with both an empty path and an empty or unset
+ * partition ID. Normalization of input keys sets the project ID (if not already set) to the project
+ * ID from the request.
+ *
+ *
Sample for DatastoreClient:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ * String projectId = "projectId-894832108";
+ * ReadOptions readOptions = ReadOptions.newBuilder().build();
+ * List keys = new ArrayList<>();
+ * LookupResponse response = datastoreClient.lookup(projectId, readOptions, keys);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.datastore.v1;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java
new file mode 100644
index 000000000..3b2b170bd
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1.stub;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.datastore.v1.AllocateIdsRequest;
+import com.google.datastore.v1.AllocateIdsResponse;
+import com.google.datastore.v1.BeginTransactionRequest;
+import com.google.datastore.v1.BeginTransactionResponse;
+import com.google.datastore.v1.CommitRequest;
+import com.google.datastore.v1.CommitResponse;
+import com.google.datastore.v1.LookupRequest;
+import com.google.datastore.v1.LookupResponse;
+import com.google.datastore.v1.ReserveIdsRequest;
+import com.google.datastore.v1.ReserveIdsResponse;
+import com.google.datastore.v1.RollbackRequest;
+import com.google.datastore.v1.RollbackResponse;
+import com.google.datastore.v1.RunAggregationQueryRequest;
+import com.google.datastore.v1.RunAggregationQueryResponse;
+import com.google.datastore.v1.RunQueryRequest;
+import com.google.datastore.v1.RunQueryResponse;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the Datastore service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class DatastoreStub implements BackgroundResource {
+
+ public UnaryCallable lookupCallable() {
+ throw new UnsupportedOperationException("Not implemented: lookupCallable()");
+ }
+
+ public UnaryCallable runQueryCallable() {
+ throw new UnsupportedOperationException("Not implemented: runQueryCallable()");
+ }
+
+ public UnaryCallable
+ runAggregationQueryCallable() {
+ throw new UnsupportedOperationException("Not implemented: runAggregationQueryCallable()");
+ }
+
+ public UnaryCallable
+ beginTransactionCallable() {
+ throw new UnsupportedOperationException("Not implemented: beginTransactionCallable()");
+ }
+
+ public UnaryCallable commitCallable() {
+ throw new UnsupportedOperationException("Not implemented: commitCallable()");
+ }
+
+ public UnaryCallable rollbackCallable() {
+ throw new UnsupportedOperationException("Not implemented: rollbackCallable()");
+ }
+
+ public UnaryCallable allocateIdsCallable() {
+ throw new UnsupportedOperationException("Not implemented: allocateIdsCallable()");
+ }
+
+ public UnaryCallable reserveIdsCallable() {
+ throw new UnsupportedOperationException("Not implemented: reserveIdsCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java
new file mode 100644
index 000000000..bfc622726
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java
@@ -0,0 +1,518 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1.stub;
+
+import com.google.api.core.ApiFunction;
+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.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+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.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.v1.AllocateIdsRequest;
+import com.google.datastore.v1.AllocateIdsResponse;
+import com.google.datastore.v1.BeginTransactionRequest;
+import com.google.datastore.v1.BeginTransactionResponse;
+import com.google.datastore.v1.CommitRequest;
+import com.google.datastore.v1.CommitResponse;
+import com.google.datastore.v1.LookupRequest;
+import com.google.datastore.v1.LookupResponse;
+import com.google.datastore.v1.ReserveIdsRequest;
+import com.google.datastore.v1.ReserveIdsResponse;
+import com.google.datastore.v1.RollbackRequest;
+import com.google.datastore.v1.RollbackResponse;
+import com.google.datastore.v1.RunAggregationQueryRequest;
+import com.google.datastore.v1.RunAggregationQueryResponse;
+import com.google.datastore.v1.RunQueryRequest;
+import com.google.datastore.v1.RunQueryResponse;
+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 DatastoreStub}.
+ *
+ * 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 lookup to 30 seconds:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreStubSettings.Builder datastoreSettingsBuilder = DatastoreStubSettings.newBuilder();
+ * datastoreSettingsBuilder
+ * .lookupSettings()
+ * .setRetrySettings(
+ * datastoreSettingsBuilder
+ * .lookupSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * DatastoreStubSettings datastoreSettings = datastoreSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class DatastoreStubSettings 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 lookupSettings;
+ private final UnaryCallSettings runQuerySettings;
+ private final UnaryCallSettings
+ runAggregationQuerySettings;
+ private final UnaryCallSettings
+ beginTransactionSettings;
+ private final UnaryCallSettings commitSettings;
+ private final UnaryCallSettings rollbackSettings;
+ private final UnaryCallSettings allocateIdsSettings;
+ private final UnaryCallSettings reserveIdsSettings;
+
+ /** Returns the object with the settings used for calls to lookup. */
+ public UnaryCallSettings lookupSettings() {
+ return lookupSettings;
+ }
+
+ /** Returns the object with the settings used for calls to runQuery. */
+ public UnaryCallSettings runQuerySettings() {
+ return runQuerySettings;
+ }
+
+ /** Returns the object with the settings used for calls to runAggregationQuery. */
+ public UnaryCallSettings
+ runAggregationQuerySettings() {
+ return runAggregationQuerySettings;
+ }
+
+ /** Returns the object with the settings used for calls to beginTransaction. */
+ public UnaryCallSettings
+ beginTransactionSettings() {
+ return beginTransactionSettings;
+ }
+
+ /** Returns the object with the settings used for calls to commit. */
+ public UnaryCallSettings commitSettings() {
+ return commitSettings;
+ }
+
+ /** Returns the object with the settings used for calls to rollback. */
+ public UnaryCallSettings rollbackSettings() {
+ return rollbackSettings;
+ }
+
+ /** Returns the object with the settings used for calls to allocateIds. */
+ public UnaryCallSettings allocateIdsSettings() {
+ return allocateIdsSettings;
+ }
+
+ /** Returns the object with the settings used for calls to reserveIds. */
+ public UnaryCallSettings reserveIdsSettings() {
+ return reserveIdsSettings;
+ }
+
+ public DatastoreStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcDatastoreStub.create(this);
+ }
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonDatastoreStub.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 gRPC ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
+ 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 defaultGrpcApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DatastoreStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DatastoreStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return DatastoreStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new REST builder for this class. */
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
+ /** 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 DatastoreStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ lookupSettings = settingsBuilder.lookupSettings().build();
+ runQuerySettings = settingsBuilder.runQuerySettings().build();
+ runAggregationQuerySettings = settingsBuilder.runAggregationQuerySettings().build();
+ beginTransactionSettings = settingsBuilder.beginTransactionSettings().build();
+ commitSettings = settingsBuilder.commitSettings().build();
+ rollbackSettings = settingsBuilder.rollbackSettings().build();
+ allocateIdsSettings = settingsBuilder.allocateIdsSettings().build();
+ reserveIdsSettings = settingsBuilder.reserveIdsSettings().build();
+ }
+
+ /** Builder for DatastoreStubSettings. */
+ public static class Builder extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+ private final UnaryCallSettings.Builder lookupSettings;
+ private final UnaryCallSettings.Builder runQuerySettings;
+ private final UnaryCallSettings.Builder
+ runAggregationQuerySettings;
+ private final UnaryCallSettings.Builder
+ beginTransactionSettings;
+ private final UnaryCallSettings.Builder commitSettings;
+ private final UnaryCallSettings.Builder rollbackSettings;
+ private final UnaryCallSettings.Builder
+ allocateIdsSettings;
+ private final UnaryCallSettings.Builder
+ reserveIdsSettings;
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "retry_policy_0_codes",
+ ImmutableSet.copyOf(
+ Lists.newArrayList(
+ StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED)));
+ definitions.put(
+ "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList()));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ 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_0_params", settings);
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRpcTimeout(Duration.ofMillis(60000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(60000L))
+ .setTotalTimeout(Duration.ofMillis(60000L))
+ .build();
+ definitions.put("no_retry_1_params", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ lookupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ runQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ runAggregationQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ allocateIdsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ reserveIdsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ lookupSettings,
+ runQuerySettings,
+ runAggregationQuerySettings,
+ beginTransactionSettings,
+ commitSettings,
+ rollbackSettings,
+ allocateIdsSettings,
+ reserveIdsSettings);
+ initDefaults(this);
+ }
+
+ protected Builder(DatastoreStubSettings settings) {
+ super(settings);
+
+ lookupSettings = settings.lookupSettings.toBuilder();
+ runQuerySettings = settings.runQuerySettings.toBuilder();
+ runAggregationQuerySettings = settings.runAggregationQuerySettings.toBuilder();
+ beginTransactionSettings = settings.beginTransactionSettings.toBuilder();
+ commitSettings = settings.commitSettings.toBuilder();
+ rollbackSettings = settings.rollbackSettings.toBuilder();
+ allocateIdsSettings = settings.allocateIdsSettings.toBuilder();
+ reserveIdsSettings = settings.reserveIdsSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ lookupSettings,
+ runQuerySettings,
+ runAggregationQuerySettings,
+ beginTransactionSettings,
+ commitSettings,
+ rollbackSettings,
+ allocateIdsSettings,
+ reserveIdsSettings);
+ }
+
+ 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 createHttpJsonDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+ builder
+ .lookupSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .runQuerySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .runAggregationQuerySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .beginTransactionSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
+
+ builder
+ .commitSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
+
+ builder
+ .rollbackSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
+
+ builder
+ .allocateIdsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
+
+ builder
+ .reserveIdsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ 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 lookup. */
+ public UnaryCallSettings.Builder lookupSettings() {
+ return lookupSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to runQuery. */
+ public UnaryCallSettings.Builder runQuerySettings() {
+ return runQuerySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to runAggregationQuery. */
+ public UnaryCallSettings.Builder
+ runAggregationQuerySettings() {
+ return runAggregationQuerySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to beginTransaction. */
+ public UnaryCallSettings.Builder
+ beginTransactionSettings() {
+ return beginTransactionSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to commit. */
+ public UnaryCallSettings.Builder commitSettings() {
+ return commitSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to rollback. */
+ public UnaryCallSettings.Builder rollbackSettings() {
+ return rollbackSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to allocateIds. */
+ public UnaryCallSettings.Builder
+ allocateIdsSettings() {
+ return allocateIdsSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to reserveIds. */
+ public UnaryCallSettings.Builder reserveIdsSettings() {
+ return reserveIdsSettings;
+ }
+
+ @Override
+ public DatastoreStubSettings build() throws IOException {
+ return new DatastoreStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java
new file mode 100644
index 000000000..4e640ead2
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.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 Datastore service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcDatastoreCallableFactory 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/v1/stub/GrpcDatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java
new file mode 100644
index 000000000..f68e8996b
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java
@@ -0,0 +1,429 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1.stub;
+
+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.RequestParamsBuilder;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.api.pathtemplate.PathTemplate;
+import com.google.datastore.v1.AllocateIdsRequest;
+import com.google.datastore.v1.AllocateIdsResponse;
+import com.google.datastore.v1.BeginTransactionRequest;
+import com.google.datastore.v1.BeginTransactionResponse;
+import com.google.datastore.v1.CommitRequest;
+import com.google.datastore.v1.CommitResponse;
+import com.google.datastore.v1.LookupRequest;
+import com.google.datastore.v1.LookupResponse;
+import com.google.datastore.v1.ReserveIdsRequest;
+import com.google.datastore.v1.ReserveIdsResponse;
+import com.google.datastore.v1.RollbackRequest;
+import com.google.datastore.v1.RollbackResponse;
+import com.google.datastore.v1.RunAggregationQueryRequest;
+import com.google.datastore.v1.RunAggregationQueryResponse;
+import com.google.datastore.v1.RunQueryRequest;
+import com.google.datastore.v1.RunQueryResponse;
+import com.google.longrunning.stub.GrpcOperationsStub;
+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 Datastore service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcDatastoreStub extends DatastoreStub {
+ private static final MethodDescriptor lookupMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/Lookup")
+ .setRequestMarshaller(ProtoUtils.marshaller(LookupRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(LookupResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ runQueryMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/RunQuery")
+ .setRequestMarshaller(ProtoUtils.marshaller(RunQueryRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(RunQueryResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ runAggregationQueryMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/RunAggregationQuery")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(RunAggregationQueryRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(RunAggregationQueryResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ beginTransactionMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/BeginTransaction")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(BeginTransactionRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(BeginTransactionResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor commitMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/Commit")
+ .setRequestMarshaller(ProtoUtils.marshaller(CommitRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(CommitResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ rollbackMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/Rollback")
+ .setRequestMarshaller(ProtoUtils.marshaller(RollbackRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(RollbackResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ allocateIdsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/AllocateIds")
+ .setRequestMarshaller(ProtoUtils.marshaller(AllocateIdsRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(AllocateIdsResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ reserveIdsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.datastore.v1.Datastore/ReserveIds")
+ .setRequestMarshaller(ProtoUtils.marshaller(ReserveIdsRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(ReserveIdsResponse.getDefaultInstance()))
+ .build();
+
+ private final UnaryCallable lookupCallable;
+ private final UnaryCallable runQueryCallable;
+ private final UnaryCallable
+ runAggregationQueryCallable;
+ private final UnaryCallable
+ beginTransactionCallable;
+ private final UnaryCallable commitCallable;
+ private final UnaryCallable rollbackCallable;
+ private final UnaryCallable allocateIdsCallable;
+ private final UnaryCallable reserveIdsCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+ private final GrpcStubCallableFactory callableFactory;
+
+ private static final PathTemplate LOOKUP_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}");
+ private static final PathTemplate LOOKUP_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate RUN_QUERY_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate RUN_QUERY_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate BEGIN_TRANSACTION_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate BEGIN_TRANSACTION_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate COMMIT_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}");
+ private static final PathTemplate COMMIT_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate ROLLBACK_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate ROLLBACK_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate ALLOCATE_IDS_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate ALLOCATE_IDS_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+ private static final PathTemplate RESERVE_IDS_0_PATH_TEMPLATE =
+ PathTemplate.create("{project_id=**}");
+ private static final PathTemplate RESERVE_IDS_1_PATH_TEMPLATE =
+ PathTemplate.create("{database_id=**}");
+
+ public static final GrpcDatastoreStub create(DatastoreStubSettings settings) throws IOException {
+ return new GrpcDatastoreStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcDatastoreStub create(ClientContext clientContext) throws IOException {
+ return new GrpcDatastoreStub(DatastoreStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcDatastoreStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcDatastoreStub(
+ DatastoreStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcDatastoreStub, 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 GrpcDatastoreStub(DatastoreStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcDatastoreCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcDatastoreStub, 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 GrpcDatastoreStub(
+ DatastoreStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings lookupTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(lookupMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", LOOKUP_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", LOOKUP_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings runQueryTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(runQueryMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", RUN_QUERY_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", RUN_QUERY_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ runAggregationQueryTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(runAggregationQueryMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(
+ request.getProjectId(),
+ "project_id",
+ RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE);
+ builder.add(
+ request.getDatabaseId(),
+ "database_id",
+ RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ beginTransactionTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(beginTransactionMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(
+ request.getProjectId(), "project_id", BEGIN_TRANSACTION_0_PATH_TEMPLATE);
+ builder.add(
+ request.getDatabaseId(),
+ "database_id",
+ BEGIN_TRANSACTION_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings commitTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(commitMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", COMMIT_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", COMMIT_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings rollbackTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(rollbackMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", ROLLBACK_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", ROLLBACK_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings allocateIdsTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(allocateIdsMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", ALLOCATE_IDS_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", ALLOCATE_IDS_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings reserveIdsTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(reserveIdsMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(request.getProjectId(), "project_id", RESERVE_IDS_0_PATH_TEMPLATE);
+ builder.add(request.getDatabaseId(), "database_id", RESERVE_IDS_1_PATH_TEMPLATE);
+ return builder.build();
+ })
+ .build();
+
+ this.lookupCallable =
+ callableFactory.createUnaryCallable(
+ lookupTransportSettings, settings.lookupSettings(), clientContext);
+ this.runQueryCallable =
+ callableFactory.createUnaryCallable(
+ runQueryTransportSettings, settings.runQuerySettings(), clientContext);
+ this.runAggregationQueryCallable =
+ callableFactory.createUnaryCallable(
+ runAggregationQueryTransportSettings,
+ settings.runAggregationQuerySettings(),
+ clientContext);
+ this.beginTransactionCallable =
+ callableFactory.createUnaryCallable(
+ beginTransactionTransportSettings, settings.beginTransactionSettings(), clientContext);
+ this.commitCallable =
+ callableFactory.createUnaryCallable(
+ commitTransportSettings, settings.commitSettings(), clientContext);
+ this.rollbackCallable =
+ callableFactory.createUnaryCallable(
+ rollbackTransportSettings, settings.rollbackSettings(), clientContext);
+ this.allocateIdsCallable =
+ callableFactory.createUnaryCallable(
+ allocateIdsTransportSettings, settings.allocateIdsSettings(), clientContext);
+ this.reserveIdsCallable =
+ callableFactory.createUnaryCallable(
+ reserveIdsTransportSettings, settings.reserveIdsSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @Override
+ public UnaryCallable lookupCallable() {
+ return lookupCallable;
+ }
+
+ @Override
+ public UnaryCallable runQueryCallable() {
+ return runQueryCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ runAggregationQueryCallable() {
+ return runAggregationQueryCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ beginTransactionCallable() {
+ return beginTransactionCallable;
+ }
+
+ @Override
+ public UnaryCallable commitCallable() {
+ return commitCallable;
+ }
+
+ @Override
+ public UnaryCallable rollbackCallable() {
+ return rollbackCallable;
+ }
+
+ @Override
+ public UnaryCallable allocateIdsCallable() {
+ return allocateIdsCallable;
+ }
+
+ @Override
+ public UnaryCallable reserveIdsCallable() {
+ return reserveIdsCallable;
+ }
+
+ @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/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java
new file mode 100644
index 000000000..8639433a7
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonCallableFactory;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.ClientContext;
+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.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST callable factory implementation for the Datastore service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonDatastoreCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java
new file mode 100644
index 000000000..c0f1c7766
--- /dev/null
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java
@@ -0,0 +1,678 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.datastore.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.RequestParamsBuilder;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.api.pathtemplate.PathTemplate;
+import com.google.datastore.v1.AllocateIdsRequest;
+import com.google.datastore.v1.AllocateIdsResponse;
+import com.google.datastore.v1.BeginTransactionRequest;
+import com.google.datastore.v1.BeginTransactionResponse;
+import com.google.datastore.v1.CommitRequest;
+import com.google.datastore.v1.CommitResponse;
+import com.google.datastore.v1.LookupRequest;
+import com.google.datastore.v1.LookupResponse;
+import com.google.datastore.v1.ReserveIdsRequest;
+import com.google.datastore.v1.ReserveIdsResponse;
+import com.google.datastore.v1.RollbackRequest;
+import com.google.datastore.v1.RollbackResponse;
+import com.google.datastore.v1.RunAggregationQueryRequest;
+import com.google.datastore.v1.RunAggregationQueryResponse;
+import com.google.datastore.v1.RunQueryRequest;
+import com.google.datastore.v1.RunQueryResponse;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the Datastore service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonDatastoreStub extends DatastoreStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor lookupMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/Lookup")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:lookup",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(LookupResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ runQueryMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/RunQuery")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:runQuery",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(RunQueryResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ runAggregationQueryMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/RunAggregationQuery")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:runAggregationQuery",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(RunAggregationQueryResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ beginTransactionMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/BeginTransaction")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:beginTransaction",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(BeginTransactionResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor commitMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/Commit")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:commit",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(CommitResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ rollbackMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/Rollback")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:rollback",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearProjectId().build(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(RollbackResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ allocateIdsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.datastore.v1.Datastore/AllocateIds")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId}:allocateIds",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map