Skip to content

Commit

Permalink
fix: update gapic-generator-java with mock service generation fixes (#…
Browse files Browse the repository at this point in the history
…960)

* chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1

PiperOrigin-RevId: 450543911

Source-Link: googleapis/googleapis@5528344

Source-Link: googleapis/googleapis-gen@9f6775c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWY2Nzc1Y2FiMTk1ODk4MmI4ODk2N2E0M2U1ZTgwNmFmMGYxMzVkYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: expose new TTL / Database Admin experimental API

PiperOrigin-RevId: 451252826

Source-Link: googleapis/googleapis@dea7c80

Source-Link: googleapis/googleapis-gen@ac376d0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWMzNzZkMDVjYjI4MDhlZTI2ZDQ1ZTJjM2EyMGY2ZmQ4NTJlNjc2ZCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: expose read_time fields in Firestore PartitionQuery and ListCollectionIds, currently only available in private preview

PiperOrigin-RevId: 453719952

Source-Link: googleapis/googleapis@bdea286

Source-Link: googleapis/googleapis-gen@03f0c73
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDNmMGM3M2EyYTljMDY0ZTZmNDk5MzU5ZmY0ZWQwNWUxODc2Mjc0MSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: Integrate new gapic-generator-java and rules_gapic

PiperOrigin-RevId: 454027580

Source-Link: googleapis/googleapis@1b22277

Source-Link: googleapis/googleapis-gen@e04cea2
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Enable REST transport for most of Java and Go clients

PiperOrigin-RevId: 456641589

Source-Link: googleapis/googleapis@8a251f5

Source-Link: googleapis/googleapis-gen@4ca52a5
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Update pom.xml

* chore: add http deps

* fix: update gapic-generator-java with mock service generation fixes

PiperOrigin-RevId: 457524730

Source-Link: googleapis/googleapis@917e7f2

Source-Link: googleapis/googleapis-gen@2497f9a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Neenu Shaji <Neenu1995@users.noreply.github.com>
Co-authored-by: Neenu1995 <neenushaji@google.com>
Co-authored-by: Alice <65933803+alicejli@users.noreply.github.com>
  • Loading branch information
5 people authored and cherylEnkidu committed Dec 11, 2023
1 parent 6169839 commit 6c72028
Show file tree
Hide file tree
Showing 41 changed files with 8,814 additions and 723 deletions.
16 changes: 16 additions & 0 deletions google-cloud-firestore-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand All @@ -75,12 +79,24 @@
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
Expand Down Expand Up @@ -60,7 +61,6 @@
import com.google.firestore.admin.v1.UpdateDatabaseRequest;
import com.google.firestore.admin.v1.UpdateFieldRequest;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
Expand Down Expand Up @@ -157,13 +157,28 @@
* FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings);
* }</pre>
*
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* FirestoreAdminSettings firestoreAdminSettings =
* FirestoreAdminSettings.newBuilder()
* .setTransportChannelProvider(
* FirestoreAdminSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class FirestoreAdminClient implements BackgroundResource {
private final FirestoreAdminSettings settings;
private final FirestoreAdminStub stub;
private final OperationsClient operationsClient;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;

/** Constructs an instance of FirestoreAdminClient with default settings. */
public static final FirestoreAdminClient create() throws IOException {
Expand All @@ -183,7 +198,6 @@ public static final FirestoreAdminClient create(FirestoreAdminSettings settings)
* Constructs an instance of FirestoreAdminClient, using the given stub for making calls. This is
* for advanced usage - prefer using create(FirestoreAdminSettings).
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final FirestoreAdminClient create(FirestoreAdminStub stub) {
return new FirestoreAdminClient(stub);
}
Expand All @@ -196,21 +210,23 @@ public static final FirestoreAdminClient create(FirestoreAdminStub stub) {
protected FirestoreAdminClient(FirestoreAdminSettings settings) throws IOException {
this.settings = settings;
this.stub = ((FirestoreAdminStubSettings) settings.getStubSettings()).createStub();
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected FirestoreAdminClient(FirestoreAdminStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}

public final FirestoreAdminSettings getSettings() {
return settings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public FirestoreAdminStub getStub() {
return stub;
}
Expand All @@ -219,10 +235,19 @@ public FirestoreAdminStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final OperationsClient getOperationsClient() {
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}

/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
@BetaApi
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a composite index. This returns a
Expand Down Expand Up @@ -518,7 +543,7 @@ public final ListIndexesPagedResponse listIndexes(ListIndexesRequest request) {
* .build();
* while (true) {
* ListIndexesResponse response = firestoreAdminClient.listIndexesCallable().call(request);
* for (Index element : response.getResponsesList()) {
* for (Index element : response.getIndexesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -1145,7 +1170,7 @@ public final UnaryCallable<ListFieldsRequest, ListFieldsPagedResponse> listField
* .build();
* while (true) {
* ListFieldsResponse response = firestoreAdminClient.listFieldsCallable().call(request);
* for (Field element : response.getResponsesList()) {
* for (Field element : response.getFieldsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -217,11 +218,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return FirestoreAdminStubSettings.defaultCredentialsProviderBuilder();
}

/** Returns a builder for the default ChannelProvider for this service. */
/** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return FirestoreAdminStubSettings.defaultGrpcTransportProviderBuilder();
}

/** Returns a builder for the default REST ChannelProvider for this service. */
@BetaApi
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return FirestoreAdminStubSettings.defaultHttpJsonTransportProviderBuilder();
}

public static TransportChannelProvider defaultTransportChannelProvider() {
return FirestoreAdminStubSettings.defaultTransportChannelProvider();
}
Expand All @@ -231,11 +239,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return FirestoreAdminStubSettings.defaultApiClientHeaderProviderBuilder();
}

/** Returns a new builder for this class. */
/** 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);
Expand Down Expand Up @@ -273,6 +287,11 @@ private static Builder createDefault() {
return new Builder(FirestoreAdminStubSettings.newBuilder());
}

@BetaApi
private static Builder createHttpJsonDefault() {
return new Builder(FirestoreAdminStubSettings.newHttpJsonBuilder());
}

public FirestoreAdminStubSettings.Builder getStubSettingsBuilder() {
return ((FirestoreAdminStubSettings.Builder) getStubSettings());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@
public abstract class FirestoreAdminStub implements BackgroundResource {

public OperationsStub getOperationsStub() {
throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
return null;
}

public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
return null;
}

public OperationCallable<CreateIndexRequest, Index, IndexOperationMetadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.grpc.ProtoOperationTransformers;
import com.google.api.gax.httpjson.GaxHttpJsonProperties;
import com.google.api.gax.httpjson.HttpJsonTransportChannel;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.longrunning.OperationSnapshot;
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
import com.google.api.gax.retrying.RetrySettings;
Expand Down Expand Up @@ -349,13 +352,17 @@ public UnaryCallSettings<UpdateDatabaseRequest, Operation> updateDatabaseSetting
return updateDatabaseOperationSettings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public FirestoreAdminStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcFirestoreAdminStub.create(this);
}
if (getTransportChannelProvider()
.getTransportName()
.equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
return HttpJsonFirestoreAdminStub.create(this);
}
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
Expand Down Expand Up @@ -388,30 +395,56 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
/** 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 defaultApiClientHeaderProviderBuilder() {
public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(FirestoreAdminStubSettings.class))
.setTransportToken(
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}

/** Returns a new builder for this class. */
@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(FirestoreAdminStubSettings.class))
.setTransportToken(
GaxHttpJsonProperties.getHttpJsonTokenName(),
GaxHttpJsonProperties.getHttpJsonVersion());
}

public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return FirestoreAdminStubSettings.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);
Expand Down Expand Up @@ -620,6 +653,19 @@ private static Builder createDefault() {
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
.createIndexSettings()
Expand Down
Loading

0 comments on commit 6c72028

Please sign in to comment.