Skip to content

chore(deps): Update gapic-generator-java to 2.26.0 #2638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.google.protobuf.Empty;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -2011,6 +2013,49 @@ public final UnaryCallable<PartitionReadRequest, PartitionResponse> partitionRea
return stub.partitionReadCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Batches the supplied mutation groups in a collection of efficient transactions. All mutations
* in a group are committed atomically. However, mutations across groups can be committed
* non-atomically in an unspecified order and thus, they must be independent of each other.
* Partial failure is possible, i.e., some groups may have been committed successfully, while some
* may have failed. The results of individual batches are streamed into the response as the
* batches are applied.
*
* <p>BatchWrite requests are not replay protected, meaning that each mutation group may be
* applied more than once. Replays of non-idempotent mutations may have undesirable effects. For
* example, replays of an insert mutation may produce an already exists error or if you use
* generated or commit timestamp-based keys, it may result in additional rows being added to the
* mutation's table. We recommend structuring your mutation groups to be idempotent to avoid this
* issue.
*
* <p>Sample code:
*
* <pre>{@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 (SpannerClient spannerClient = SpannerClient.create()) {
* BatchWriteRequest request =
* BatchWriteRequest.newBuilder()
* .setSession(
* SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString())
* .setRequestOptions(RequestOptions.newBuilder().build())
* .addAllMutationGroups(new ArrayList<BatchWriteRequest.MutationGroup>())
* .build();
* ServerStream<BatchWriteResponse> stream = spannerClient.batchWriteCallable().call(request);
* for (BatchWriteResponse response : stream) {
* // Do something when a response is received.
* }
* }
* }</pre>
*/
public final ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable() {
return stub.batchWriteCallable();
}

@Override
public final void close() {
stub.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import com.google.protobuf.Empty;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -177,6 +179,11 @@ public UnaryCallSettings<PartitionReadRequest, PartitionResponse> partitionReadS
return ((SpannerStubSettings) getStubSettings()).partitionReadSettings();
}

/** Returns the object with the settings used for calls to batchWrite. */
public ServerStreamingCallSettings<BatchWriteRequest, BatchWriteResponse> batchWriteSettings() {
return ((SpannerStubSettings) getStubSettings()).batchWriteSettings();
}

public static final SpannerSettings create(SpannerStubSettings stub) throws IOException {
return new SpannerSettings.Builder(stub.toBuilder()).build();
}
Expand Down Expand Up @@ -375,6 +382,12 @@ public UnaryCallSettings.Builder<RollbackRequest, Empty> rollbackSettings() {
return getStubSettingsBuilder().partitionReadSettings();
}

/** Returns the builder for the settings used for calls to batchWrite. */
public ServerStreamingCallSettings.Builder<BatchWriteRequest, BatchWriteResponse>
batchWriteSettings() {
return getStubSettingsBuilder().batchWriteSettings();
}

@Override
public SpannerSettings build() throws IOException {
return new SpannerSettings(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"BatchCreateSessions": {
"methods": ["batchCreateSessions", "batchCreateSessions", "batchCreateSessions", "batchCreateSessionsCallable"]
},
"BatchWrite": {
"methods": ["batchWriteCallable"]
},
"BeginTransaction": {
"methods": ["beginTransaction", "beginTransaction", "beginTransaction", "beginTransactionCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.google.protobuf.Empty;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -202,6 +204,15 @@ public class GrpcSpannerStub extends SpannerStub {
.setResponseMarshaller(ProtoUtils.marshaller(PartitionResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<BatchWriteRequest, BatchWriteResponse>
batchWriteMethodDescriptor =
MethodDescriptor.<BatchWriteRequest, BatchWriteResponse>newBuilder()
.setType(MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName("google.spanner.v1.Spanner/BatchWrite")
.setRequestMarshaller(ProtoUtils.marshaller(BatchWriteRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(BatchWriteResponse.getDefaultInstance()))
.build();

private final UnaryCallable<CreateSessionRequest, Session> createSessionCallable;
private final UnaryCallable<BatchCreateSessionsRequest, BatchCreateSessionsResponse>
batchCreateSessionsCallable;
Expand All @@ -222,6 +233,7 @@ public class GrpcSpannerStub extends SpannerStub {
private final UnaryCallable<RollbackRequest, Empty> rollbackCallable;
private final UnaryCallable<PartitionQueryRequest, PartitionResponse> partitionQueryCallable;
private final UnaryCallable<PartitionReadRequest, PartitionResponse> partitionReadCallable;
private final ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable;

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
Expand Down Expand Up @@ -414,6 +426,16 @@ protected GrpcSpannerStub(
return builder.build();
})
.build();
GrpcCallSettings<BatchWriteRequest, BatchWriteResponse> batchWriteTransportSettings =
GrpcCallSettings.<BatchWriteRequest, BatchWriteResponse>newBuilder()
.setMethodDescriptor(batchWriteMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("session", String.valueOf(request.getSession()));
return builder.build();
})
.build();

this.createSessionCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -467,6 +489,9 @@ protected GrpcSpannerStub(
this.partitionReadCallable =
callableFactory.createUnaryCallable(
partitionReadTransportSettings, settings.partitionReadSettings(), clientContext);
this.batchWriteCallable =
callableFactory.createServerStreamingCallable(
batchWriteTransportSettings, settings.batchWriteSettings(), clientContext);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
Expand Down Expand Up @@ -558,6 +583,11 @@ public UnaryCallable<PartitionReadRequest, PartitionResponse> partitionReadCalla
return partitionReadCallable;
}

@Override
public ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable() {
return batchWriteCallable;
}

@Override
public final void close() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.google.protobuf.TypeRegistry;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -618,6 +620,43 @@ public class HttpJsonSpannerStub extends SpannerStub {
.build())
.build();

private static final ApiMethodDescriptor<BatchWriteRequest, BatchWriteResponse>
batchWriteMethodDescriptor =
ApiMethodDescriptor.<BatchWriteRequest, BatchWriteResponse>newBuilder()
.setFullMethodName("google.spanner.v1.Spanner/BatchWrite")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING)
.setRequestFormatter(
ProtoMessageRequestFormatter.<BatchWriteRequest>newBuilder()
.setPath(
"/v1/{session=projects/*/instances/*/databases/*/sessions/*}:batchWrite",
request -> {
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<BatchWriteRequest> serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "session", request.getSession());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map<String, List<String>> fields = new HashMap<>();
ProtoRestSerializer<BatchWriteRequest> serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearSession().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.<BatchWriteResponse>newBuilder()
.setDefaultInstance(BatchWriteResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();

private final UnaryCallable<CreateSessionRequest, Session> createSessionCallable;
private final UnaryCallable<BatchCreateSessionsRequest, BatchCreateSessionsResponse>
batchCreateSessionsCallable;
Expand All @@ -638,6 +677,7 @@ public class HttpJsonSpannerStub extends SpannerStub {
private final UnaryCallable<RollbackRequest, Empty> rollbackCallable;
private final UnaryCallable<PartitionQueryRequest, PartitionResponse> partitionQueryCallable;
private final UnaryCallable<PartitionReadRequest, PartitionResponse> partitionReadCallable;
private final ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable;

private final BackgroundResource backgroundResources;
private final HttpJsonStubCallableFactory callableFactory;
Expand Down Expand Up @@ -846,6 +886,17 @@ protected HttpJsonSpannerStub(
return builder.build();
})
.build();
HttpJsonCallSettings<BatchWriteRequest, BatchWriteResponse> batchWriteTransportSettings =
HttpJsonCallSettings.<BatchWriteRequest, BatchWriteResponse>newBuilder()
.setMethodDescriptor(batchWriteMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("session", String.valueOf(request.getSession()));
return builder.build();
})
.build();

this.createSessionCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -899,6 +950,9 @@ protected HttpJsonSpannerStub(
this.partitionReadCallable =
callableFactory.createUnaryCallable(
partitionReadTransportSettings, settings.partitionReadSettings(), clientContext);
this.batchWriteCallable =
callableFactory.createServerStreamingCallable(
batchWriteTransportSettings, settings.batchWriteSettings(), clientContext);

this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
Expand All @@ -922,6 +976,7 @@ public static List<ApiMethodDescriptor> getMethodDescriptors() {
methodDescriptors.add(rollbackMethodDescriptor);
methodDescriptors.add(partitionQueryMethodDescriptor);
methodDescriptors.add(partitionReadMethodDescriptor);
methodDescriptors.add(batchWriteMethodDescriptor);
return methodDescriptors;
}

Expand Down Expand Up @@ -1007,6 +1062,11 @@ public UnaryCallable<PartitionReadRequest, PartitionResponse> partitionReadCalla
return partitionReadCallable;
}

@Override
public ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable() {
return batchWriteCallable;
}

@Override
public final void close() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.google.protobuf.Empty;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -121,6 +123,10 @@ public UnaryCallable<PartitionReadRequest, PartitionResponse> partitionReadCalla
throw new UnsupportedOperationException("Not implemented: partitionReadCallable()");
}

public ServerStreamingCallable<BatchWriteRequest, BatchWriteResponse> batchWriteCallable() {
throw new UnsupportedOperationException("Not implemented: batchWriteCallable()");
}

@Override
public abstract void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import com.google.protobuf.Empty;
import com.google.spanner.v1.BatchCreateSessionsRequest;
import com.google.spanner.v1.BatchCreateSessionsResponse;
import com.google.spanner.v1.BatchWriteRequest;
import com.google.spanner.v1.BatchWriteResponse;
import com.google.spanner.v1.BeginTransactionRequest;
import com.google.spanner.v1.CommitRequest;
import com.google.spanner.v1.CommitResponse;
Expand Down Expand Up @@ -141,6 +143,8 @@ public class SpannerStubSettings extends StubSettings<SpannerStubSettings> {
private final UnaryCallSettings<RollbackRequest, Empty> rollbackSettings;
private final UnaryCallSettings<PartitionQueryRequest, PartitionResponse> partitionQuerySettings;
private final UnaryCallSettings<PartitionReadRequest, PartitionResponse> partitionReadSettings;
private final ServerStreamingCallSettings<BatchWriteRequest, BatchWriteResponse>
batchWriteSettings;

private static final PagedListDescriptor<ListSessionsRequest, ListSessionsResponse, Session>
LIST_SESSIONS_PAGE_STR_DESC =
Expand Down Expand Up @@ -274,6 +278,11 @@ public UnaryCallSettings<PartitionReadRequest, PartitionResponse> partitionReadS
return partitionReadSettings;
}

/** Returns the object with the settings used for calls to batchWrite. */
public ServerStreamingCallSettings<BatchWriteRequest, BatchWriteResponse> batchWriteSettings() {
return batchWriteSettings;
}

public SpannerStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
Expand Down Expand Up @@ -393,6 +402,7 @@ protected SpannerStubSettings(Builder settingsBuilder) throws IOException {
rollbackSettings = settingsBuilder.rollbackSettings().build();
partitionQuerySettings = settingsBuilder.partitionQuerySettings().build();
partitionReadSettings = settingsBuilder.partitionReadSettings().build();
batchWriteSettings = settingsBuilder.batchWriteSettings().build();
}

/** Builder for SpannerStubSettings. */
Expand Down Expand Up @@ -422,6 +432,8 @@ public static class Builder extends StubSettings.Builder<SpannerStubSettings, Bu
partitionQuerySettings;
private final UnaryCallSettings.Builder<PartitionReadRequest, PartitionResponse>
partitionReadSettings;
private final ServerStreamingCallSettings.Builder<BatchWriteRequest, BatchWriteResponse>
batchWriteSettings;
private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
RETRYABLE_CODE_DEFINITIONS;

Expand Down Expand Up @@ -513,6 +525,7 @@ protected Builder(ClientContext clientContext) {
rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
partitionQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
partitionReadSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
batchWriteSettings = ServerStreamingCallSettings.newBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand Down Expand Up @@ -550,6 +563,7 @@ protected Builder(SpannerStubSettings settings) {
rollbackSettings = settings.rollbackSettings.toBuilder();
partitionQuerySettings = settings.partitionQuerySettings.toBuilder();
partitionReadSettings = settings.partitionReadSettings.toBuilder();
batchWriteSettings = settings.batchWriteSettings.toBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand Down Expand Up @@ -670,6 +684,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.batchWriteSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));

return builder;
}

Expand Down Expand Up @@ -772,6 +791,12 @@ public UnaryCallSettings.Builder<RollbackRequest, Empty> rollbackSettings() {
return partitionReadSettings;
}

/** Returns the builder for the settings used for calls to batchWrite. */
public ServerStreamingCallSettings.Builder<BatchWriteRequest, BatchWriteResponse>
batchWriteSettings() {
return batchWriteSettings;
}

@Override
public SpannerStubSettings build() throws IOException {
return new SpannerStubSettings(this);
Expand Down
Loading