Skip to content

Commit

Permalink
feat: add firestore aggregation query apis to the stable googleapis b…
Browse files Browse the repository at this point in the history
…ranch (#1030)
  • Loading branch information
gcf-owl-bot[bot] committed Sep 15, 2022
1 parent 5acd8e4 commit 0e3e2ac
Show file tree
Hide file tree
Showing 40 changed files with 10,628 additions and 549 deletions.
5 changes: 5 additions & 0 deletions google-cloud-firestore-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@
* <p>For example, to set the total timeout of getIndex to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* // 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
* FirestoreAdminSettings.Builder firestoreAdminSettingsBuilder =
* FirestoreAdminSettings.newBuilder();
* firestoreAdminSettingsBuilder
* .getIndexSettings()
* .setRetrySettings(
* firestoreAdminSettingsBuilder
* .getIndexSettings()
* .getRetrySettings()
* .toBuilder()
* firestoreAdminSettingsBuilder.getIndexSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* FirestoreAdminSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@
* <p>Sample for FirestoreAdminClient:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* // 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 (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
* IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
* Index response = firestoreAdminClient.getIndex(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@
* <p>For example, to set the total timeout of getIndex to 30 seconds:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* // 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
* FirestoreAdminStubSettings.Builder firestoreAdminSettingsBuilder =
* FirestoreAdminStubSettings.newBuilder();
* firestoreAdminSettingsBuilder
* .getIndexSettings()
* .setRetrySettings(
* firestoreAdminSettingsBuilder
* .getIndexSettings()
* .getRetrySettings()
* .toBuilder()
* firestoreAdminSettingsBuilder.getIndexSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
* .build());
* FirestoreAdminStubSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub {
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create().toBody("index", request.getIndex()))
ProtoRestSerializer.create()
.toBody("index", request.getIndex(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -290,7 +291,8 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub {
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create().toBody("field", request.getField()))
ProtoRestSerializer.create()
.toBody("field", request.getField(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -365,7 +367,7 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub {
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build()))
.toBody("*", request.toBuilder().clearName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -404,7 +406,7 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub {
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearName().build()))
.toBody("*", request.toBuilder().clearName().build(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down Expand Up @@ -511,7 +513,7 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub {
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("database", request.getDatabase()))
.toBody("database", request.getDatabase(), false))
.build())
.setResponseParser(
ProtoMessageResponseParser.<Operation>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@
@Generated("by gapic-generator-java")
public class FirestoreAdminClientTest {
private static MockFirestoreAdmin mockFirestoreAdmin;
private static MockLocations mockLocations;
private static MockServiceHelper mockServiceHelper;
private LocalChannelProvider channelProvider;
private FirestoreAdminClient client;

@BeforeClass
public static void startStaticServer() {
mockFirestoreAdmin = new MockFirestoreAdmin();
mockLocations = new MockLocations();
mockServiceHelper =
new MockServiceHelper(
UUID.randomUUID().toString(), Arrays.<MockGrpcService>asList(mockFirestoreAdmin));
UUID.randomUUID().toString(),
Arrays.<MockGrpcService>asList(mockFirestoreAdmin, mockLocations));
mockServiceHelper.start();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.firestore.v1;

import com.google.api.core.BetaApi;
import com.google.api.gax.grpc.testing.MockGrpcService;
import com.google.protobuf.AbstractMessage;
import io.grpc.ServerServiceDefinition;
import java.util.List;
import javax.annotation.Generated;

@BetaApi
@Generated("by gapic-generator-java")
public class MockLocations implements MockGrpcService {
private final MockLocationsImpl serviceImpl;

public MockLocations() {
serviceImpl = new MockLocationsImpl();
}

@Override
public List<AbstractMessage> getRequests() {
return serviceImpl.getRequests();
}

@Override
public void addResponse(AbstractMessage response) {
serviceImpl.addResponse(response);
}

@Override
public void addException(Exception exception) {
serviceImpl.addException(exception);
}

@Override
public ServerServiceDefinition getServiceDefinition() {
return serviceImpl.bindService();
}

@Override
public void reset() {
serviceImpl.reset();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.firestore.v1;

import com.google.api.core.BetaApi;
import com.google.cloud.location.LocationsGrpc.LocationsImplBase;
import com.google.protobuf.AbstractMessage;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import javax.annotation.Generated;

@BetaApi
@Generated("by gapic-generator-java")
public class MockLocationsImpl extends LocationsImplBase {
private List<AbstractMessage> requests;
private Queue<Object> responses;

public MockLocationsImpl() {
requests = new ArrayList<>();
responses = new LinkedList<>();
}

public List<AbstractMessage> getRequests() {
return requests;
}

public void addResponse(AbstractMessage response) {
responses.add(response);
}

public void setResponses(List<AbstractMessage> responses) {
this.responses = new LinkedList<Object>(responses);
}

public void addException(Exception exception) {
responses.add(exception);
}

public void reset() {
requests = new ArrayList<>();
responses = new LinkedList<>();
}
}
5 changes: 5 additions & 0 deletions google-cloud-firestore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-conformance-tests</artifactId>
Expand Down
Loading

0 comments on commit 0e3e2ac

Please sign in to comment.