From 6c720286e98768335c869b935881f58bdc5a86e9 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 12:16:48 -0600 Subject: [PATCH] fix: update gapic-generator-java with mock service generation fixes (#960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 PiperOrigin-RevId: 450543911 Source-Link: https://github.com/googleapis/googleapis/commit/55283447ab72f10b6c2571d770af0498b593e84f Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f6775cab1958982b88967a43e5e806af0f135db 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: https://github.com/googleapis/googleapis/commit/dea7c804bc35acaa54b9d9704240fbdda1213a52 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ac376d05cb2808ee26d45e2c3a20f6fd852e676d 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: https://github.com/googleapis/googleapis/commit/bdea28692664f78d151ae0e6799b565ce2006767 Source-Link: https://github.com/googleapis/googleapis-gen/commit/03f0c73a2a9c064e6f499359ff4ed05e18762741 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: https://github.com/googleapis/googleapis/commit/1b222777baa702e7135610355706570ed2b56318 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638 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: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb 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: https://github.com/googleapis/googleapis/commit/917e7f21cb1dc062744c6694437cdd46219f28cb Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 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 Co-authored-by: Neenu Shaji Co-authored-by: Neenu1995 Co-authored-by: Alice <65933803+alicejli@users.noreply.github.com> --- google-cloud-firestore-admin/pom.xml | 16 + .../firestore/v1/FirestoreAdminClient.java | 45 +- .../firestore/v1/FirestoreAdminSettings.java | 23 +- .../firestore/v1/stub/FirestoreAdminStub.java | 6 +- .../v1/stub/FirestoreAdminStubSettings.java | 54 +- ...HttpJsonFirestoreAdminCallableFactory.java | 105 ++ .../v1/stub/HttpJsonFirestoreAdminStub.java | 894 ++++++++++ .../v1/FirestoreAdminClientHttpJsonTest.java | 1167 +++++++++++++ .../v1/FirestoreAdminClientTest.java | 6 + google-cloud-firestore/pom.xml | 16 + .../cloud/firestore/v1/FirestoreClient.java | 24 +- .../cloud/firestore/v1/FirestoreSettings.java | 23 +- .../v1/stub/FirestoreStubSettings.java | 53 +- .../HttpJsonFirestoreCallableFactory.java | 105 ++ .../v1/stub/HttpJsonFirestoreStub.java | 904 ++++++++++ .../v1/FirestoreClientHttpJsonTest.java | 725 ++++++++ .../firestore/v1/FirestoreClientTest.java | 1 + .../google/firestore/admin/v1/Database.java | 592 ++++++- .../firestore/admin/v1/DatabaseOrBuilder.java | 64 + .../firestore/admin/v1/DatabaseProto.java | 61 +- .../com/google/firestore/admin/v1/Field.java | 1491 +++++++++++++++-- .../admin/v1/FieldOperationMetadata.java | 1239 +++++++++++++- .../v1/FieldOperationMetadataOrBuilder.java | 39 + .../firestore/admin/v1/FieldOrBuilder.java | 41 + .../google/firestore/admin/v1/FieldProto.java | 53 +- .../admin/v1/FirestoreAdminProto.java | 240 ++- .../google/firestore/admin/v1/IndexProto.java | 57 +- .../firestore/admin/v1/LocationProto.java | 25 +- .../firestore/admin/v1/OperationProto.java | 135 +- .../google/firestore/admin/v1/database.proto | 53 +- .../google/firestore/admin/v1/field.proto | 40 +- .../firestore/admin/v1/firestore_admin.proto | 4 +- .../google/firestore/admin/v1/index.proto | 37 +- .../google/firestore/admin/v1/location.proto | 5 +- .../google/firestore/admin/v1/operation.proto | 24 +- .../google/firestore/v1/FirestoreProto.java | 292 ++-- .../v1/ListCollectionIdsRequest.java | 390 +++++ .../v1/ListCollectionIdsRequestOrBuilder.java | 41 + .../firestore/v1/PartitionQueryRequest.java | 390 +++++ .../v1/PartitionQueryRequestOrBuilder.java | 41 + .../proto/google/firestore/v1/firestore.proto | 16 + 41 files changed, 8814 insertions(+), 723 deletions(-) create mode 100644 google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java create mode 100644 google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java create mode 100644 google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java create mode 100644 google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java diff --git a/google-cloud-firestore-admin/pom.xml b/google-cloud-firestore-admin/pom.xml index 94f24395d..3efefb997 100644 --- a/google-cloud-firestore-admin/pom.xml +++ b/google-cloud-firestore-admin/pom.xml @@ -54,6 +54,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + com.google.guava guava @@ -75,12 +79,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java index f88b65654..baefebd67 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java @@ -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; @@ -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; @@ -157,13 +157,28 @@ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@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);
+ * }
+ * *

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 { @@ -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); } @@ -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; } @@ -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 @@ -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(); @@ -1145,7 +1170,7 @@ public final UnaryCallable 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(); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java index aca16c4ce..a9f66be1c 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java @@ -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; @@ -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(); } @@ -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); @@ -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()); } diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java index 8626f778a..c497c5968 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java @@ -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 diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java index 8c03cef52..46074b6e2 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java @@ -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; @@ -349,13 +352,17 @@ public UnaryCallSettings 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())); @@ -388,18 +395,25 @@ 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)) @@ -407,11 +421,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil 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); @@ -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() diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java new file mode 100644 index 000000000..342c32d63 --- /dev/null +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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.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 FirestoreAdmin service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirestoreAdminCallableFactory + 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-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java new file mode 100644 index 000000000..8d71663a4 --- /dev/null +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java @@ -0,0 +1,894 @@ +/* + * 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.stub; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +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.HttpJsonOperationSnapshot; +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.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +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 FirestoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ExportDocumentsResponse.getDescriptor()) + .add(UpdateDatabaseMetadata.getDescriptor()) + .add(Field.getDescriptor()) + .add(Empty.getDescriptor()) + .add(ImportDocumentsMetadata.getDescriptor()) + .add(Database.getDescriptor()) + .add(Index.getDescriptor()) + .add(FieldOperationMetadata.getDescriptor()) + .add(ExportDocumentsMetadata.getDescriptor()) + .add(IndexOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateIndex") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("index", request.getIndex())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateIndexRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listIndexesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListIndexes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListIndexesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetIndex") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Index.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteIndex") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getFieldMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetField") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Field.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFieldMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateField") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "field.name", request.getField().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("field", request.getField())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateFieldRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listFieldsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListFields") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFieldsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + exportDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ExportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}:exportDocuments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ImportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}:importDocuments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetDatabase") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Database.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDatabasesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListDatabases") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDatabasesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateDatabase") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database.name=projects/*/databases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "database.name", request.getDatabase().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("database", request.getDatabase())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createIndexCallable; + private final OperationCallable + createIndexOperationCallable; + private final UnaryCallable listIndexesCallable; + private final UnaryCallable + listIndexesPagedCallable; + private final UnaryCallable getIndexCallable; + private final UnaryCallable deleteIndexCallable; + private final UnaryCallable getFieldCallable; + private final UnaryCallable updateFieldCallable; + private final OperationCallable + updateFieldOperationCallable; + private final UnaryCallable listFieldsCallable; + private final UnaryCallable listFieldsPagedCallable; + private final UnaryCallable exportDocumentsCallable; + private final OperationCallable< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationCallable; + private final UnaryCallable importDocumentsCallable; + private final OperationCallable + importDocumentsOperationCallable; + private final UnaryCallable getDatabaseCallable; + private final UnaryCallable listDatabasesCallable; + private final UnaryCallable updateDatabaseCallable; + private final OperationCallable + updateDatabaseOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFirestoreAdminStub create(FirestoreAdminStubSettings settings) + throws IOException { + return new HttpJsonFirestoreAdminStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFirestoreAdminStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFirestoreAdminStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFirestoreAdminStub, 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 HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonFirestoreAdminCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFirestoreAdminStub, 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 HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listIndexesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIndexesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getFieldTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFieldMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFieldTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFieldMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFieldsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFieldsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings exportDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings importDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDatabasesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDatabasesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createIndexCallable = + callableFactory.createUnaryCallable( + createIndexTransportSettings, settings.createIndexSettings(), clientContext); + this.createIndexOperationCallable = + callableFactory.createOperationCallable( + createIndexTransportSettings, + settings.createIndexOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listIndexesCallable = + callableFactory.createUnaryCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.listIndexesPagedCallable = + callableFactory.createPagedCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.getIndexCallable = + callableFactory.createUnaryCallable( + getIndexTransportSettings, settings.getIndexSettings(), clientContext); + this.deleteIndexCallable = + callableFactory.createUnaryCallable( + deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext); + this.getFieldCallable = + callableFactory.createUnaryCallable( + getFieldTransportSettings, settings.getFieldSettings(), clientContext); + this.updateFieldCallable = + callableFactory.createUnaryCallable( + updateFieldTransportSettings, settings.updateFieldSettings(), clientContext); + this.updateFieldOperationCallable = + callableFactory.createOperationCallable( + updateFieldTransportSettings, + settings.updateFieldOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listFieldsCallable = + callableFactory.createUnaryCallable( + listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); + this.listFieldsPagedCallable = + callableFactory.createPagedCallable( + listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); + this.exportDocumentsCallable = + callableFactory.createUnaryCallable( + exportDocumentsTransportSettings, settings.exportDocumentsSettings(), clientContext); + this.exportDocumentsOperationCallable = + callableFactory.createOperationCallable( + exportDocumentsTransportSettings, + settings.exportDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDocumentsCallable = + callableFactory.createUnaryCallable( + importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); + this.importDocumentsOperationCallable = + callableFactory.createOperationCallable( + importDocumentsTransportSettings, + settings.importDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getDatabaseCallable = + callableFactory.createUnaryCallable( + getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); + this.listDatabasesCallable = + callableFactory.createUnaryCallable( + listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); + this.updateDatabaseCallable = + callableFactory.createUnaryCallable( + updateDatabaseTransportSettings, settings.updateDatabaseSettings(), clientContext); + this.updateDatabaseOperationCallable = + callableFactory.createOperationCallable( + updateDatabaseTransportSettings, + settings.updateDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createIndexMethodDescriptor); + methodDescriptors.add(listIndexesMethodDescriptor); + methodDescriptors.add(getIndexMethodDescriptor); + methodDescriptors.add(deleteIndexMethodDescriptor); + methodDescriptors.add(getFieldMethodDescriptor); + methodDescriptors.add(updateFieldMethodDescriptor); + methodDescriptors.add(listFieldsMethodDescriptor); + methodDescriptors.add(exportDocumentsMethodDescriptor); + methodDescriptors.add(importDocumentsMethodDescriptor); + methodDescriptors.add(getDatabaseMethodDescriptor); + methodDescriptors.add(listDatabasesMethodDescriptor); + methodDescriptors.add(updateDatabaseMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; + } + + @Override + public OperationCallable + createIndexOperationCallable() { + return createIndexOperationCallable; + } + + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; + } + + @Override + public UnaryCallable listIndexesPagedCallable() { + return listIndexesPagedCallable; + } + + @Override + public UnaryCallable getIndexCallable() { + return getIndexCallable; + } + + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override + public UnaryCallable getFieldCallable() { + return getFieldCallable; + } + + @Override + public UnaryCallable updateFieldCallable() { + return updateFieldCallable; + } + + @Override + public OperationCallable + updateFieldOperationCallable() { + return updateFieldOperationCallable; + } + + @Override + public UnaryCallable listFieldsCallable() { + return listFieldsCallable; + } + + @Override + public UnaryCallable listFieldsPagedCallable() { + return listFieldsPagedCallable; + } + + @Override + public UnaryCallable exportDocumentsCallable() { + return exportDocumentsCallable; + } + + @Override + public OperationCallable + exportDocumentsOperationCallable() { + return exportDocumentsOperationCallable; + } + + @Override + public UnaryCallable importDocumentsCallable() { + return importDocumentsCallable; + } + + @Override + public OperationCallable + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + + @Override + public UnaryCallable getDatabaseCallable() { + return getDatabaseCallable; + } + + @Override + public UnaryCallable listDatabasesCallable() { + return listDatabasesCallable; + } + + @Override + public UnaryCallable updateDatabaseCallable() { + return updateDatabaseCallable; + } + + @Override + public OperationCallable + updateDatabaseOperationCallable() { + return updateDatabaseOperationCallable; + } + + @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-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java new file mode 100644 index 000000000..aced3bd04 --- /dev/null +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java @@ -0,0 +1,1167 @@ +/* + * 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 static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.firestore.v1.stub.HttpJsonFirestoreAdminStub; +import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldName; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ProjectName; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreAdminClientHttpJsonTest { + private static MockHttpService mockService; + private static FirestoreAdminClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFirestoreAdminStub.getMethodDescriptors(), + FirestoreAdminSettings.getDefaultEndpoint()); + FirestoreAdminSettings settings = + FirestoreAdminSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FirestoreAdminSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreAdminClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIndexesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIndexesTest2() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + + ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIndexesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + Index actualResponse = client.getIndex(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + client.getIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + + Index actualResponse = client.getIndex(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + client.getIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIndexTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + client.deleteIndex(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + client.deleteIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIndexTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + + client.deleteIndex(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + client.deleteIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFieldTest() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); + + Field actualResponse = client.getField(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFieldExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); + client.getField(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFieldTest2() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1275/databases/database-1275/collectionGroups/collectionGroup-1275/fields/field-1275"; + + Field actualResponse = client.getField(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFieldExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1275/databases/database-1275/collectionGroups/collectionGroup-1275/fields/field-1275"; + client.getField(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFieldTest() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateFieldTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Field field = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + + Field actualResponse = client.updateFieldAsync(field).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFieldExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Field field = + Field.newBuilder() + .setName( + FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + client.updateFieldAsync(field).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listFieldsTest() throws Exception { + Field responsesElement = Field.newBuilder().build(); + ListFieldsResponse expectedResponse = + ListFieldsResponse.newBuilder() + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + ListFieldsPagedResponse pagedListResponse = client.listFields(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFieldsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFieldsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + client.listFields(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFieldsTest2() throws Exception { + Field responsesElement = Field.newBuilder().build(); + ListFieldsResponse expectedResponse = + ListFieldsResponse.newBuilder() + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + + ListFieldsPagedResponse pagedListResponse = client.listFields(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFieldsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFieldsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + client.listFields(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void exportDocumentsTest() throws Exception { + ExportDocumentsResponse expectedResponse = + ExportDocumentsResponse.newBuilder().setOutputUriPrefix("outputUriPrefix499858205").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ExportDocumentsResponse actualResponse = client.exportDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.exportDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void exportDocumentsTest2() throws Exception { + ExportDocumentsResponse expectedResponse = + ExportDocumentsResponse.newBuilder().setOutputUriPrefix("outputUriPrefix499858205").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + ExportDocumentsResponse actualResponse = client.exportDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.exportDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.importDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.importDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2580/databases/database-2580"; + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDatabaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder().addAllDatabases(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDatabasesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest2() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder().addAllDatabases(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDatabasesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Database database = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Database actualResponse = client.updateDatabaseAsync(database, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Database database = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDatabaseAsync(database, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java index f8c7c7bab..322489ce3 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java @@ -452,6 +452,7 @@ public void getFieldTest() throws Exception { Field.newBuilder() .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) .build(); mockFirestoreAdmin.addResponse(expectedResponse); @@ -491,6 +492,7 @@ public void getFieldTest2() throws Exception { Field.newBuilder() .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) .build(); mockFirestoreAdmin.addResponse(expectedResponse); @@ -530,6 +532,7 @@ public void updateFieldTest() throws Exception { Field.newBuilder() .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -838,6 +841,7 @@ public void getDatabaseTest() throws Exception { Database.newBuilder() .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") .setEtag("etag3123477") .build(); mockFirestoreAdmin.addResponse(expectedResponse); @@ -878,6 +882,7 @@ public void getDatabaseTest2() throws Exception { Database.newBuilder() .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") .setEtag("etag3123477") .build(); mockFirestoreAdmin.addResponse(expectedResponse); @@ -990,6 +995,7 @@ public void updateDatabaseTest() throws Exception { Database.newBuilder() .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) .setLocationId("locationId1541836720") + .setKeyPrefix("keyPrefix-2076395055") .setEtag("etag3123477") .build(); Operation resultOperation = diff --git a/google-cloud-firestore/pom.xml b/google-cloud-firestore/pom.xml index a65e0d62d..ce795c6ed 100644 --- a/google-cloud-firestore/pom.xml +++ b/google-cloud-firestore/pom.xml @@ -79,6 +79,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + com.google.guava guava @@ -131,12 +135,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + com.google.cloud google-cloud-conformance-tests diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java index 6ccfa91a4..e05f16e1d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -140,6 +139,20 @@ * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * FirestoreSettings firestoreSettings =
+ *     FirestoreSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             FirestoreSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * FirestoreClient firestoreClient = FirestoreClient.create(firestoreSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -164,7 +177,6 @@ public static final FirestoreClient create(FirestoreSettings settings) throws IO * Constructs an instance of FirestoreClient, using the given stub for making calls. This is for * advanced usage - prefer using create(FirestoreSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final FirestoreClient create(FirestoreStub stub) { return new FirestoreClient(stub); } @@ -178,7 +190,6 @@ protected FirestoreClient(FirestoreSettings settings) throws IOException { this.stub = ((FirestoreStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected FirestoreClient(FirestoreStub stub) { this.settings = null; this.stub = stub; @@ -188,7 +199,6 @@ public final FirestoreSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public FirestoreStub getStub() { return stub; } @@ -332,7 +342,7 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque * .build(); * while (true) { * ListDocumentsResponse response = firestoreClient.listDocumentsCallable().call(request); - * for (Document element : response.getResponsesList()) { + * for (Document element : response.getDocumentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -886,7 +896,7 @@ public final PartitionQueryPagedResponse partitionQuery(PartitionQueryRequest re * .build(); * while (true) { * PartitionQueryResponse response = firestoreClient.partitionQueryCallable().call(request); - * for (Cursor element : response.getResponsesList()) { + * for (Cursor element : response.getPartitionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1068,7 +1078,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR * while (true) { * ListCollectionIdsResponse response = * firestoreClient.listCollectionIdsCallable().call(request); - * for (String element : response.getResponsesList()) { + * for (String element : response.getCollectionIdsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java index 904f6634f..de1559c24 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java @@ -25,6 +25,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; @@ -207,11 +208,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return FirestoreStubSettings.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 FirestoreStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FirestoreStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return FirestoreStubSettings.defaultTransportChannelProvider(); } @@ -221,11 +229,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return FirestoreStubSettings.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); @@ -263,6 +277,11 @@ private static Builder createDefault() { return new Builder(FirestoreStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(FirestoreStubSettings.newHttpJsonBuilder()); + } + public FirestoreStubSettings.Builder getStubSettingsBuilder() { return ((FirestoreStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java index b6a57db10..7349f89e8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java @@ -29,6 +29,9 @@ 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.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -394,13 +397,17 @@ public UnaryCallSettings createDocumentSettings return createDocumentSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public FirestoreStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFirestoreStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFirestoreStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -433,29 +440,54 @@ 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(FirestoreStubSettings.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(FirestoreStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirestoreStubSettings.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); @@ -719,6 +751,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 .getDocumentSettings() diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java new file mode 100644 index 000000000..ef1a2b580 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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.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 Firestore service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirestoreCallableFactory + 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-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java new file mode 100644 index 000000000..e3d62a242 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java @@ -0,0 +1,904 @@ +/* + * 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.stub; + +import static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; + +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.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.protobuf.Empty; +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 Firestore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirestoreStub extends FirestoreStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/GetDocument") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + serializer.putQueryParam( + fields, "transaction", request.getTransaction()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ListDocuments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents/*/**}/{collectionId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "collectionId", request.getCollectionId()); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents}/{collectionId}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + serializer.putQueryParam( + fields, "showMissing", request.getShowMissing()); + serializer.putQueryParam( + fields, "transaction", request.getTransaction()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/UpdateDocument") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{document.name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "document.name", request.getDocument().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "currentDocument", request.getCurrentDocument()); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/DeleteDocument") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "currentDocument", request.getCurrentDocument()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchGetDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BatchGetDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:batchGet", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchGetDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + beginTransactionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BeginTransaction") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:beginTransaction", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BeginTransactionResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor commitMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/Commit") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:commit", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CommitResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor rollbackMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/Rollback") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:rollback", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/RunQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:runQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RunQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + partitionQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/PartitionQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:partitionQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PartitionQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listCollectionIdsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ListCollectionIds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCollectionIdsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchWriteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BatchWrite") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:batchWrite", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchWriteResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/CreateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents/**}/{collectionId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "collectionId", request.getCollectionId()); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "documentId", request.getDocumentId()); + serializer.putQueryParam(fields, "mask", request.getMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getDocumentCallable; + private final UnaryCallable listDocumentsCallable; + private final UnaryCallable + listDocumentsPagedCallable; + private final UnaryCallable updateDocumentCallable; + private final UnaryCallable deleteDocumentCallable; + private final ServerStreamingCallable + batchGetDocumentsCallable; + private final UnaryCallable + beginTransactionCallable; + private final UnaryCallable commitCallable; + private final UnaryCallable rollbackCallable; + private final ServerStreamingCallable runQueryCallable; + private final UnaryCallable partitionQueryCallable; + private final UnaryCallable + partitionQueryPagedCallable; + private final UnaryCallable + listCollectionIdsCallable; + private final UnaryCallable + listCollectionIdsPagedCallable; + private final UnaryCallable batchWriteCallable; + private final UnaryCallable createDocumentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFirestoreStub create(FirestoreStubSettings settings) + throws IOException { + return new HttpJsonFirestoreStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFirestoreStub create(ClientContext clientContext) throws IOException { + return new HttpJsonFirestoreStub( + FirestoreStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFirestoreStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFirestoreStub( + FirestoreStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFirestoreStub, 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 HttpJsonFirestoreStub(FirestoreStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFirestoreCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFirestoreStub, 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 HttpJsonFirestoreStub( + FirestoreStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchGetDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchGetDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + beginTransactionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(beginTransactionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings commitTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(commitMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings rollbackTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rollbackMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + partitionQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(partitionQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listCollectionIdsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCollectionIdsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchWriteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchWriteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getDocumentCallable = + callableFactory.createUnaryCallable( + getDocumentTransportSettings, settings.getDocumentSettings(), clientContext); + this.listDocumentsCallable = + callableFactory.createUnaryCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.listDocumentsPagedCallable = + callableFactory.createPagedCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.updateDocumentCallable = + callableFactory.createUnaryCallable( + updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); + this.deleteDocumentCallable = + callableFactory.createUnaryCallable( + deleteDocumentTransportSettings, settings.deleteDocumentSettings(), clientContext); + this.batchGetDocumentsCallable = + callableFactory.createServerStreamingCallable( + batchGetDocumentsTransportSettings, + settings.batchGetDocumentsSettings(), + 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.runQueryCallable = + callableFactory.createServerStreamingCallable( + runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.partitionQueryCallable = + callableFactory.createUnaryCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + this.partitionQueryPagedCallable = + callableFactory.createPagedCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + this.listCollectionIdsCallable = + callableFactory.createUnaryCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.listCollectionIdsPagedCallable = + callableFactory.createPagedCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.batchWriteCallable = + callableFactory.createUnaryCallable( + batchWriteTransportSettings, settings.batchWriteSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getDocumentMethodDescriptor); + methodDescriptors.add(listDocumentsMethodDescriptor); + methodDescriptors.add(updateDocumentMethodDescriptor); + methodDescriptors.add(deleteDocumentMethodDescriptor); + methodDescriptors.add(batchGetDocumentsMethodDescriptor); + methodDescriptors.add(beginTransactionMethodDescriptor); + methodDescriptors.add(commitMethodDescriptor); + methodDescriptors.add(rollbackMethodDescriptor); + methodDescriptors.add(runQueryMethodDescriptor); + methodDescriptors.add(partitionQueryMethodDescriptor); + methodDescriptors.add(listCollectionIdsMethodDescriptor); + methodDescriptors.add(batchWriteMethodDescriptor); + methodDescriptors.add(createDocumentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; + } + + @Override + public UnaryCallable listDocumentsCallable() { + return listDocumentsCallable; + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; + } + + @Override + public UnaryCallable updateDocumentCallable() { + return updateDocumentCallable; + } + + @Override + public UnaryCallable deleteDocumentCallable() { + return deleteDocumentCallable; + } + + @Override + public ServerStreamingCallable + batchGetDocumentsCallable() { + return batchGetDocumentsCallable; + } + + @Override + public UnaryCallable + beginTransactionCallable() { + return beginTransactionCallable; + } + + @Override + public UnaryCallable commitCallable() { + return commitCallable; + } + + @Override + public UnaryCallable rollbackCallable() { + return rollbackCallable; + } + + @Override + public ServerStreamingCallable runQueryCallable() { + return runQueryCallable; + } + + @Override + public UnaryCallable partitionQueryCallable() { + return partitionQueryCallable; + } + + @Override + public UnaryCallable + partitionQueryPagedCallable() { + return partitionQueryPagedCallable; + } + + @Override + public UnaryCallable + listCollectionIdsCallable() { + return listCollectionIdsCallable; + } + + @Override + public UnaryCallable + listCollectionIdsPagedCallable() { + return listCollectionIdsPagedCallable; + } + + @Override + public UnaryCallable batchWriteCallable() { + return batchWriteCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; + } + + @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-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java new file mode 100644 index 000000000..50c0a3548 --- /dev/null +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java @@ -0,0 +1,725 @@ +/* + * 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 static com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.firestore.v1.stub.HttpJsonFirestoreStub; +import com.google.common.collect.Lists; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import com.google.firestore.v1.WriteResult; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreClientHttpJsonTest { + private static MockHttpService mockService; + private static FirestoreClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFirestoreStub.getMethodDescriptors(), FirestoreSettings.getDefaultEndpoint()); + FirestoreSettings settings = + FirestoreSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FirestoreSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .setMask(DocumentMask.newBuilder().build()) + .build(); + + Document actualResponse = client.getDocument(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .setMask(DocumentMask.newBuilder().build()) + .build(); + client.getDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + "projects/project-6440/databases/database-6440/documents/document-6440/document-6440") + .setCollectionId("collectionId-3631") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setMask(DocumentMask.newBuilder().build()) + .setShowMissing(true) + .build(); + + ListDocumentsPagedResponse pagedListResponse = client.listDocuments(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + "projects/project-6440/databases/database-6440/documents/document-6440/document-6440") + .setCollectionId("collectionId-3631") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setMask(DocumentMask.newBuilder().build()) + .setShowMissing(true) + .build(); + client.listDocuments(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Document document = + Document.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + DocumentMask updateMask = DocumentMask.newBuilder().build(); + + Document actualResponse = client.updateDocument(document, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Document document = + Document.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + DocumentMask updateMask = DocumentMask.newBuilder().build(); + client.updateDocument(document, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDocumentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-615/databases/database-615/documents/document-615/document-615"; + + client.deleteDocument(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-615/databases/database-615/documents/document-615/document-615"; + client.deleteDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchGetDocumentsTest() throws Exception {} + + @Test + public void batchGetDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void beginTransactionTest() throws Exception { + BeginTransactionResponse expectedResponse = + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + + BeginTransactionResponse actualResponse = client.beginTransaction(database); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void beginTransactionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + client.beginTransaction(database); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + List writes = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(database, writes); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void commitExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + List writes = new ArrayList<>(); + client.commit(database, writes); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void rollbackTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + ByteString transaction = ByteString.EMPTY; + + client.rollback(database, transaction); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void rollbackExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + ByteString transaction = ByteString.EMPTY; + client.rollback(database, transaction); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runQueryTest() throws Exception {} + + @Test + public void runQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void partitionQueryTest() throws Exception { + Cursor responsesElement = Cursor.newBuilder().build(); + PartitionQueryResponse expectedResponse = + PartitionQueryResponse.newBuilder() + .setNextPageToken("") + .addAllPartitions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("projects/project-9316/databases/database-9316/documents") + .setPartitionCount(-1738969222) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + PartitionQueryPagedResponse pagedListResponse = client.partitionQuery(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPartitionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void partitionQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("projects/project-9316/databases/database-9316/documents") + .setPartitionCount(-1738969222) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.partitionQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void writeUnsupportedMethodTest() throws Exception { + // The write() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void listenUnsupportedMethodTest() throws Exception { + // The listen() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void listCollectionIdsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListCollectionIdsResponse expectedResponse = + ListCollectionIdsResponse.newBuilder() + .setNextPageToken("") + .addAllCollectionIds(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9316/databases/database-9316/documents"; + + ListCollectionIdsPagedResponse pagedListResponse = client.listCollectionIds(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCollectionIdsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCollectionIdsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9316/databases/database-9316/documents"; + client.listCollectionIds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchWriteTest() throws Exception { + BatchWriteResponse expectedResponse = + BatchWriteResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .addAllStatus(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("projects/project-4060/databases/database-4060") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); + + BatchWriteResponse actualResponse = client.batchWrite(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchWriteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("projects/project-4060/databases/database-4060") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); + client.batchWrite(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("projects/project-2701/databases/database-2701/documents/document-2701") + .setCollectionId("collectionId-3631") + .setDocumentId("documentId-814940266") + .setDocument(Document.newBuilder().build()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + + Document actualResponse = client.createDocument(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("projects/project-2701/databases/database-2701/documents/document-2701") + .setCollectionId("collectionId-3631") + .setDocumentId("documentId-814940266") + .setDocument(Document.newBuilder().build()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + client.createDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java index 0fd563bc5..a3bc2ebb9 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java @@ -568,6 +568,7 @@ public void partitionQueryTest() throws Exception { Assert.assertEquals(request.getPartitionCount(), actualRequest.getPartitionCount()); Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getReadTime(), actualRequest.getReadTime()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java index 6c2f7307d..51d336d9f 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java @@ -44,6 +44,8 @@ private Database() { locationId_ = ""; type_ = 0; concurrencyMode_ = 0; + appEngineIntegrationMode_ = 0; + keyPrefix_ = ""; etag_ = ""; } @@ -104,6 +106,20 @@ private Database( concurrencyMode_ = rawValue; break; } + case 152: + { + int rawValue = input.readEnum(); + + appEngineIntegrationMode_ = rawValue; + break; + } + case 162: + { + java.lang.String s = input.readStringRequireUtf8(); + + keyPrefix_ = s; + break; + } case 794: { java.lang.String s = input.readStringRequireUtf8(); @@ -154,6 +170,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * The type of the database. * See https://cloud.google.com/datastore/docs/firestore-or-datastore for * information about how to choose. + * Mode changes are only allowed if the database is empty. * * * Protobuf enum {@code google.firestore.admin.v1.Database.DatabaseType} @@ -330,8 +347,8 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *

-     * Use optimistic concurrency control by default. This setting is available
-     * for Cloud Firestore customers.
+     * Use optimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
      * 
* * OPTIMISTIC = 1; @@ -341,8 +358,8 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *
-     * Use pessimistic concurrency control by default. This setting is available
-     * for Cloud Firestore customers.
+     * Use pessimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
      * This is the default setting for Cloud Firestore.
      * 
* @@ -353,9 +370,10 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *
-     * Use optimistic concurrency control with entity groups by default. This is
-     * the only available setting for Cloud Datastore customers.
-     * This is the default setting for Cloud Datastore.
+     * Use optimistic concurrency control with entity groups by default.
+     * This is the only available mode for Cloud Datastore.
+     * This mode is also available for Cloud Firestore with Datastore Mode but
+     * is not recommended.
      * 
* * OPTIMISTIC_WITH_ENTITY_GROUPS = 3; @@ -378,8 +396,8 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *
-     * Use optimistic concurrency control by default. This setting is available
-     * for Cloud Firestore customers.
+     * Use optimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
      * 
* * OPTIMISTIC = 1; @@ -389,8 +407,8 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *
-     * Use pessimistic concurrency control by default. This setting is available
-     * for Cloud Firestore customers.
+     * Use pessimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
      * This is the default setting for Cloud Firestore.
      * 
* @@ -401,9 +419,10 @@ public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { * * *
-     * Use optimistic concurrency control with entity groups by default. This is
-     * the only available setting for Cloud Datastore customers.
-     * This is the default setting for Cloud Datastore.
+     * Use optimistic concurrency control with entity groups by default.
+     * This is the only available mode for Cloud Datastore.
+     * This mode is also available for Cloud Firestore with Datastore Mode but
+     * is not recommended.
      * 
* * OPTIMISTIC_WITH_ENTITY_GROUPS = 3; @@ -497,6 +516,174 @@ private ConcurrencyMode(int value) { // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.ConcurrencyMode) } + /** + * + * + *
+   * The type of App Engine integration mode.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.AppEngineIntegrationMode} + */ + public enum AppEngineIntegrationMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + */ + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * If an App Engine application exists in the same region as this database,
+     * App Engine configuration will impact this database. This includes
+     * disabling of the application & database, as well as disabling writes to
+     * the database.
+     * 
+ * + * ENABLED = 1; + */ + ENABLED(1), + /** + * + * + *
+     * Appengine has no affect on the ability of this database to serve
+     * requests.
+     * 
+ * + * DISABLED = 2; + */ + DISABLED(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Not used.
+     * 
+ * + * APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + */ + public static final int APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * If an App Engine application exists in the same region as this database,
+     * App Engine configuration will impact this database. This includes
+     * disabling of the application & database, as well as disabling writes to
+     * the database.
+     * 
+ * + * ENABLED = 1; + */ + public static final int ENABLED_VALUE = 1; + /** + * + * + *
+     * Appengine has no affect on the ability of this database to serve
+     * requests.
+     * 
+ * + * DISABLED = 2; + */ + public static final int DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static AppEngineIntegrationMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static AppEngineIntegrationMode forNumber(int value) { + switch (value) { + case 0: + return APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED; + case 1: + return ENABLED; + case 2: + return DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public AppEngineIntegrationMode findValueByNumber(int number) { + return AppEngineIntegrationMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(2); + } + + private static final AppEngineIntegrationMode[] VALUES = values(); + + public static AppEngineIntegrationMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private AppEngineIntegrationMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.AppEngineIntegrationMode) + } + public static final int NAME_FIELD_NUMBER = 1; private volatile java.lang.Object name_; /** @@ -679,6 +866,109 @@ public com.google.firestore.admin.v1.Database.ConcurrencyMode getConcurrencyMode : result; } + public static final int APP_ENGINE_INTEGRATION_MODE_FIELD_NUMBER = 19; + private int appEngineIntegrationMode_; + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + @java.lang.Override + public int getAppEngineIntegrationModeValue() { + return appEngineIntegrationMode_; + } + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + getAppEngineIntegrationMode() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode result = + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.valueOf( + appEngineIntegrationMode_); + return result == null + ? com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.UNRECOGNIZED + : result; + } + + public static final int KEY_PREFIX_FIELD_NUMBER = 20; + private volatile java.lang.Object keyPrefix_; + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in combination
+   * with the project id ("<key prefix>~<project id>") to construct the
+   * application id that is returned from the Cloud Datastore APIs in Google App
+   * Engine first generation runtimes.
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + @java.lang.Override + public java.lang.String getKeyPrefix() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyPrefix_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in combination
+   * with the project id ("<key prefix>~<project id>") to construct the
+   * application id that is returned from the Cloud Datastore APIs in Google App
+   * Engine first generation runtimes.
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKeyPrefixBytes() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + keyPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + public static final int ETAG_FIELD_NUMBER = 99; private volatile java.lang.Object etag_; /** @@ -762,6 +1052,15 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io .getNumber()) { output.writeEnum(15, concurrencyMode_); } + if (appEngineIntegrationMode_ + != com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + .APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(19, appEngineIntegrationMode_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(keyPrefix_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 20, keyPrefix_); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(etag_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 99, etag_); } @@ -790,6 +1089,15 @@ public int getSerializedSize() { .getNumber()) { size += com.google.protobuf.CodedOutputStream.computeEnumSize(15, concurrencyMode_); } + if (appEngineIntegrationMode_ + != com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + .APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(19, appEngineIntegrationMode_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(keyPrefix_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(20, keyPrefix_); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(etag_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(99, etag_); } @@ -812,6 +1120,8 @@ public boolean equals(final java.lang.Object obj) { if (!getLocationId().equals(other.getLocationId())) return false; if (type_ != other.type_) return false; if (concurrencyMode_ != other.concurrencyMode_) return false; + if (appEngineIntegrationMode_ != other.appEngineIntegrationMode_) return false; + if (!getKeyPrefix().equals(other.getKeyPrefix())) return false; if (!getEtag().equals(other.getEtag())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; @@ -832,6 +1142,10 @@ public int hashCode() { hash = (53 * hash) + type_; hash = (37 * hash) + CONCURRENCY_MODE_FIELD_NUMBER; hash = (53 * hash) + concurrencyMode_; + hash = (37 * hash) + APP_ENGINE_INTEGRATION_MODE_FIELD_NUMBER; + hash = (53 * hash) + appEngineIntegrationMode_; + hash = (37 * hash) + KEY_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getKeyPrefix().hashCode(); hash = (37 * hash) + ETAG_FIELD_NUMBER; hash = (53 * hash) + getEtag().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); @@ -989,6 +1303,10 @@ public Builder clear() { concurrencyMode_ = 0; + appEngineIntegrationMode_ = 0; + + keyPrefix_ = ""; + etag_ = ""; return this; @@ -1022,6 +1340,8 @@ public com.google.firestore.admin.v1.Database buildPartial() { result.locationId_ = locationId_; result.type_ = type_; result.concurrencyMode_ = concurrencyMode_; + result.appEngineIntegrationMode_ = appEngineIntegrationMode_; + result.keyPrefix_ = keyPrefix_; result.etag_ = etag_; onBuilt(); return result; @@ -1086,6 +1406,13 @@ public Builder mergeFrom(com.google.firestore.admin.v1.Database other) { if (other.concurrencyMode_ != 0) { setConcurrencyModeValue(other.getConcurrencyModeValue()); } + if (other.appEngineIntegrationMode_ != 0) { + setAppEngineIntegrationModeValue(other.getAppEngineIntegrationModeValue()); + } + if (!other.getKeyPrefix().isEmpty()) { + keyPrefix_ = other.keyPrefix_; + onChanged(); + } if (!other.getEtag().isEmpty()) { etag_ = other.etag_; onChanged(); @@ -1538,6 +1865,243 @@ public Builder clearConcurrencyMode() { return this; } + private int appEngineIntegrationMode_ = 0; + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + @java.lang.Override + public int getAppEngineIntegrationModeValue() { + return appEngineIntegrationMode_; + } + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @param value The enum numeric value on the wire for appEngineIntegrationMode to set. + * @return This builder for chaining. + */ + public Builder setAppEngineIntegrationModeValue(int value) { + + appEngineIntegrationMode_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + getAppEngineIntegrationMode() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode result = + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.valueOf( + appEngineIntegrationMode_); + return result == null + ? com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @param value The appEngineIntegrationMode to set. + * @return This builder for chaining. + */ + public Builder setAppEngineIntegrationMode( + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode value) { + if (value == null) { + throw new NullPointerException(); + } + + appEngineIntegrationMode_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return This builder for chaining. + */ + public Builder clearAppEngineIntegrationMode() { + + appEngineIntegrationMode_ = 0; + onChanged(); + return this; + } + + private java.lang.Object keyPrefix_ = ""; + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in combination
+     * with the project id ("<key prefix>~<project id>") to construct the
+     * application id that is returned from the Cloud Datastore APIs in Google App
+     * Engine first generation runtimes.
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + public java.lang.String getKeyPrefix() { + java.lang.Object ref = keyPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in combination
+     * with the project id ("<key prefix>~<project id>") to construct the
+     * application id that is returned from the Cloud Datastore APIs in Google App
+     * Engine first generation runtimes.
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + public com.google.protobuf.ByteString getKeyPrefixBytes() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + keyPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in combination
+     * with the project id ("<key prefix>~<project id>") to construct the
+     * application id that is returned from the Cloud Datastore APIs in Google App
+     * Engine first generation runtimes.
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The keyPrefix to set. + * @return This builder for chaining. + */ + public Builder setKeyPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + keyPrefix_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in combination
+     * with the project id ("<key prefix>~<project id>") to construct the
+     * application id that is returned from the Cloud Datastore APIs in Google App
+     * Engine first generation runtimes.
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearKeyPrefix() { + + keyPrefix_ = getDefaultInstance().getKeyPrefix(); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in combination
+     * with the project id ("<key prefix>~<project id>") to construct the
+     * application id that is returned from the Cloud Datastore APIs in Google App
+     * Engine first generation runtimes.
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for keyPrefix to set. + * @return This builder for chaining. + */ + public Builder setKeyPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + keyPrefix_ = value; + onChanged(); + return this; + } + private java.lang.Object etag_ = ""; /** * diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java index 496bf7484..c47da06ff 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java @@ -131,6 +131,70 @@ public interface DatabaseOrBuilder */ com.google.firestore.admin.v1.Database.ConcurrencyMode getConcurrencyMode(); + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + int getAppEngineIntegrationModeValue(); + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode getAppEngineIntegrationMode(); + + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in combination
+   * with the project id ("<key prefix>~<project id>") to construct the
+   * application id that is returned from the Cloud Datastore APIs in Google App
+   * Engine first generation runtimes.
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + java.lang.String getKeyPrefix(); + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in combination
+   * with the project id ("<key prefix>~<project id>") to construct the
+   * application id that is returned from the Cloud Datastore APIs in Google App
+   * Engine first generation runtimes.
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + com.google.protobuf.ByteString getKeyPrefixBytes(); + /** * * diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java index 394170ace..9924cab19 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java @@ -43,27 +43,31 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "\n(google/firestore/admin/v1/database.pro" + "to\022\031google.firestore.admin.v1\032\037google/ap" + "i/field_behavior.proto\032\031google/api/resou" - + "rce.proto\032\036google/protobuf/duration.prot" - + "o\032\037google/protobuf/timestamp.proto\032\034goog" - + "le/api/annotations.proto\"\360\003\n\010Database\022\014\n" - + "\004name\030\001 \001(\t\022\023\n\013location_id\030\t \001(\t\022>\n\004type" - + "\030\n \001(\01620.google.firestore.admin.v1.Datab" - + "ase.DatabaseType\022M\n\020concurrency_mode\030\017 \001" - + "(\01623.google.firestore.admin.v1.Database." - + "ConcurrencyMode\022\014\n\004etag\030c \001(\t\"W\n\014Databas" - + "eType\022\035\n\031DATABASE_TYPE_UNSPECIFIED\020\000\022\024\n\020" - + "FIRESTORE_NATIVE\020\001\022\022\n\016DATASTORE_MODE\020\002\"w" - + "\n\017ConcurrencyMode\022 \n\034CONCURRENCY_MODE_UN" - + "SPECIFIED\020\000\022\016\n\nOPTIMISTIC\020\001\022\017\n\013PESSIMIST" - + "IC\020\002\022!\n\035OPTIMISTIC_WITH_ENTITY_GROUPS\020\003:" - + "R\352AO\n!firestore.googleapis.com/Database\022" - + "\'projects/{project}/databases/{database}" - + "R\001\001B\341\001\n\035com.google.firestore.admin.v1B\rD" - + "atabaseProtoP\001Z>google.golang.org/genpro" - + "to/googleapis/firestore/admin/v1;admin\242\002" - + "\004GCFS\252\002\037Google.Cloud.Firestore.Admin.V1\312" - + "\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Goog" - + "le::Cloud::Firestore::Admin::V1b\006proto3" + + "rce.proto\"\320\005\n\010Database\022\014\n\004name\030\001 \001(\t\022\023\n\013" + + "location_id\030\t \001(\t\022>\n\004type\030\n \001(\01620.google" + + ".firestore.admin.v1.Database.DatabaseTyp" + + "e\022M\n\020concurrency_mode\030\017 \001(\01623.google.fir" + + "estore.admin.v1.Database.ConcurrencyMode" + + "\022a\n\033app_engine_integration_mode\030\023 \001(\0162<." + + "google.firestore.admin.v1.Database.AppEn" + + "gineIntegrationMode\022\027\n\nkey_prefix\030\024 \001(\tB" + + "\003\340A\003\022\014\n\004etag\030c \001(\t\"W\n\014DatabaseType\022\035\n\031DA" + + "TABASE_TYPE_UNSPECIFIED\020\000\022\024\n\020FIRESTORE_N" + + "ATIVE\020\001\022\022\n\016DATASTORE_MODE\020\002\"w\n\017Concurren" + + "cyMode\022 \n\034CONCURRENCY_MODE_UNSPECIFIED\020\000" + + "\022\016\n\nOPTIMISTIC\020\001\022\017\n\013PESSIMISTIC\020\002\022!\n\035OPT" + + "IMISTIC_WITH_ENTITY_GROUPS\020\003\"b\n\030AppEngin" + + "eIntegrationMode\022+\n\'APP_ENGINE_INTEGRATI" + + "ON_MODE_UNSPECIFIED\020\000\022\013\n\007ENABLED\020\001\022\014\n\010DI" + + "SABLED\020\002:R\352AO\n!firestore.googleapis.com/" + + "Database\022\'projects/{project}/databases/{" + + "database}R\001\001B\341\001\n\035com.google.firestore.ad" + + "min.v1B\rDatabaseProtoP\001Z>google.golang.o" + + "rg/genproto/googleapis/firestore/admin/v" + + "1;admin\242\002\004GCFS\252\002\037Google.Cloud.Firestore." + + "Admin.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\" + + "V1\352\002#Google::Cloud::Firestore::Admin::V1" + + "b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -71,9 +75,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.Descriptors.FileDescriptor[] { com.google.api.FieldBehaviorProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), - com.google.protobuf.DurationProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_Database_descriptor = getDescriptor().getMessageTypes().get(0); @@ -81,18 +82,22 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_Database_descriptor, new java.lang.String[] { - "Name", "LocationId", "Type", "ConcurrencyMode", "Etag", + "Name", + "LocationId", + "Type", + "ConcurrencyMode", + "AppEngineIntegrationMode", + "KeyPrefix", + "Etag", }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); registry.add(com.google.api.ResourceProto.resource); com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( descriptor, registry); com.google.api.FieldBehaviorProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); - com.google.protobuf.DurationProto.getDescriptor(); - com.google.protobuf.TimestampProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java index 2b478e00c..c9451f52b 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java @@ -93,6 +93,22 @@ private Field( indexConfig_ = subBuilder.buildPartial(); } + break; + } + case 26: + { + com.google.firestore.admin.v1.Field.TtlConfig.Builder subBuilder = null; + if (ttlConfig_ != null) { + subBuilder = ttlConfig_.toBuilder(); + } + ttlConfig_ = + input.readMessage( + com.google.firestore.admin.v1.Field.TtlConfig.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(ttlConfig_); + ttlConfig_ = subBuilder.buildPartial(); + } + break; } default: @@ -1591,195 +1607,1104 @@ public com.google.firestore.admin.v1.Field.IndexConfig getDefaultInstanceForType } } - public static final int NAME_FIELD_NUMBER = 1; - private volatile java.lang.Object name_; - /** - * - * - *
-   * Required. A field name of the form
-   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
-   * A field path may be a simple field name, e.g. `address` or a path to fields
-   * within map_value , e.g. `address.city`,
-   * or a special field path. The only valid special field is `*`, which
-   * represents any field.
-   * Field paths may be quoted using ` (backtick). The only character that needs
-   * to be escaped within a quoted field path is the backtick character itself,
-   * escaped using a backslash. Special characters in field paths that
-   * must be quoted include: `*`, `.`,
-   * ``` (backtick), `[`, `]`, as well as any ascii symbolic characters.
-   * Examples:
-   * (Note: Comments here are written in markdown syntax, so there is an
-   *  additional layer of backticks to represent a code block)
-   * `\`address.city\`` represents a field named `address.city`, not the map key
-   * `city` in the field `address`.
-   * `\`*\`` represents a field named `*`, not any field.
-   * A special `Field` contains the default indexing settings for all fields.
-   * This field's resource name is:
-   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
-   * Indexes defined on this `Field` will be applied to all fields which do not
-   * have their own `Field` index configuration.
-   * 
- * - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The name. - */ - @java.lang.Override - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - name_ = s; - return s; - } + public interface TtlConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Field.TtlConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.firestore.admin.v1.Field.TtlConfig.State getState(); } /** * * *
-   * Required. A field name of the form
-   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
-   * A field path may be a simple field name, e.g. `address` or a path to fields
-   * within map_value , e.g. `address.city`,
-   * or a special field path. The only valid special field is `*`, which
-   * represents any field.
-   * Field paths may be quoted using ` (backtick). The only character that needs
-   * to be escaped within a quoted field path is the backtick character itself,
-   * escaped using a backslash. Special characters in field paths that
-   * must be quoted include: `*`, `.`,
-   * ``` (backtick), `[`, `]`, as well as any ascii symbolic characters.
-   * Examples:
-   * (Note: Comments here are written in markdown syntax, so there is an
-   *  additional layer of backticks to represent a code block)
-   * `\`address.city\`` represents a field named `address.city`, not the map key
-   * `city` in the field `address`.
-   * `\`*\`` represents a field named `*`, not any field.
-   * A special `Field` contains the default indexing settings for all fields.
-   * This field's resource name is:
-   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
-   * Indexes defined on this `Field` will be applied to all fields which do not
-   * have their own `Field` index configuration.
+   * The TTL (time-to-live) configuration for documents that have this `Field`
+   * set.
+   * Storing a timestamp value into a TTL-enabled field will be treated as
+   * the document's absolute expiration time. Using any other data type or
+   * leaving the field absent will disable the TTL for the individual document.
    * 
* - * string name = 1 [(.google.api.field_behavior) = REQUIRED]; - * - * @return The bytes for name. + * Protobuf type {@code google.firestore.admin.v1.Field.TtlConfig} */ - @java.lang.Override - public com.google.protobuf.ByteString getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; + public static final class TtlConfig extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Field.TtlConfig) + TtlConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use TtlConfig.newBuilder() to construct. + private TtlConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); } - } - public static final int INDEX_CONFIG_FIELD_NUMBER = 2; - private com.google.firestore.admin.v1.Field.IndexConfig indexConfig_; - /** - * - * - *
-   * The index configuration for this field. If unset, field indexing will
-   * revert to the configuration defined by the `ancestor_field`. To
-   * explicitly remove all indexes for this field, specify an index config
-   * with an empty list of indexes.
-   * 
- * - * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; - * - * @return Whether the indexConfig field is set. - */ - @java.lang.Override - public boolean hasIndexConfig() { - return indexConfig_ != null; - } - /** - * - * - *
-   * The index configuration for this field. If unset, field indexing will
-   * revert to the configuration defined by the `ancestor_field`. To
-   * explicitly remove all indexes for this field, specify an index config
-   * with an empty list of indexes.
-   * 
- * - * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; - * - * @return The indexConfig. - */ - @java.lang.Override - public com.google.firestore.admin.v1.Field.IndexConfig getIndexConfig() { - return indexConfig_ == null - ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() - : indexConfig_; - } - /** - * - * - *
-   * The index configuration for this field. If unset, field indexing will
-   * revert to the configuration defined by the `ancestor_field`. To
-   * explicitly remove all indexes for this field, specify an index config
-   * with an empty list of indexes.
-   * 
- * - * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; - */ - @java.lang.Override - public com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder() { - return getIndexConfig(); - } + private TtlConfig() { + state_ = 0; + } - private byte memoizedIsInitialized = -1; + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TtlConfig(); + } - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } - memoizedIsInitialized = 1; - return true; - } + private TtlConfig( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + int rawValue = input.readEnum(); - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); - } - if (indexConfig_ != null) { - output.writeMessage(2, getIndexConfig()); + state_ = rawValue; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } } - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; } - if (indexConfig_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndexConfig()); + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.TtlConfig.class, + com.google.firestore.admin.v1.Field.TtlConfig.Builder.class); } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - @java.lang.Override + /** + * + * + *
+     * The state of applying the TTL configuration to all documents.
+     * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Field.TtlConfig.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The state is unspecified or unknown.
+       * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+       * The TTL is being applied. There is an active long-running operation to
+       * track the change. Newly written documents will have TTLs applied as
+       * requested. Requested TTLs on existing documents are still being
+       * processed. When TTLs on all existing documents have been processed, the
+       * state will move to 'ACTIVE'.
+       * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+       * The TTL is active for all documents.
+       * 
+ * + * ACTIVE = 2; + */ + ACTIVE(2), + /** + * + * + *
+       * The TTL configuration could not be enabled for all existing documents.
+       * Newly written documents will continue to have their TTL applied.
+       * The LRO returned when last attempting to enable TTL for this `Field`
+       * has failed, and may have more details.
+       * 
+ * + * NEEDS_REPAIR = 3; + */ + NEEDS_REPAIR(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+       * The state is unspecified or unknown.
+       * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+       * The TTL is being applied. There is an active long-running operation to
+       * track the change. Newly written documents will have TTLs applied as
+       * requested. Requested TTLs on existing documents are still being
+       * processed. When TTLs on all existing documents have been processed, the
+       * state will move to 'ACTIVE'.
+       * 
+ * + * CREATING = 1; + */ + public static final int CREATING_VALUE = 1; + /** + * + * + *
+       * The TTL is active for all documents.
+       * 
+ * + * ACTIVE = 2; + */ + public static final int ACTIVE_VALUE = 2; + /** + * + * + *
+       * The TTL configuration could not be enabled for all existing documents.
+       * Newly written documents will continue to have their TTL applied.
+       * The LRO returned when last attempting to enable TTL for this `Field`
+       * has failed, and may have more details.
+       * 
+ * + * NEEDS_REPAIR = 3; + */ + public static final int NEEDS_REPAIR_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return CREATING; + case 2: + return ACTIVE; + case 3: + return NEEDS_REPAIR; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Field.TtlConfig.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Field.TtlConfig.State) + } + + public static final int STATE_FIELD_NUMBER = 1; + private int state_; + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig.State getState() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.Field.TtlConfig.State result = + com.google.firestore.admin.v1.Field.TtlConfig.State.valueOf(state_); + return result == null + ? com.google.firestore.admin.v1.Field.TtlConfig.State.UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (state_ + != com.google.firestore.admin.v1.Field.TtlConfig.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(1, state_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (state_ + != com.google.firestore.admin.v1.Field.TtlConfig.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, state_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Field.TtlConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Field.TtlConfig other = + (com.google.firestore.admin.v1.Field.TtlConfig) obj; + + if (state_ != other.state_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Field.TtlConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * The TTL (time-to-live) configuration for documents that have this `Field`
+     * set.
+     * Storing a timestamp value into a TTL-enabled field will be treated as
+     * the document's absolute expiration time. Using any other data type or
+     * leaving the field absent will disable the TTL for the individual document.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field.TtlConfig} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Field.TtlConfig) + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.TtlConfig.class, + com.google.firestore.admin.v1.Field.TtlConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Field.TtlConfig.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + state_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig build() { + com.google.firestore.admin.v1.Field.TtlConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig buildPartial() { + com.google.firestore.admin.v1.Field.TtlConfig result = + new com.google.firestore.admin.v1.Field.TtlConfig(this); + result.state_ = state_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Field.TtlConfig) { + return mergeFrom((com.google.firestore.admin.v1.Field.TtlConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Field.TtlConfig other) { + if (other == com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance()) + return this; + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.firestore.admin.v1.Field.TtlConfig parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.firestore.admin.v1.Field.TtlConfig) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int state_ = 0; + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + + state_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig.State getState() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.Field.TtlConfig.State result = + com.google.firestore.admin.v1.Field.TtlConfig.State.valueOf(state_); + return result == null + ? com.google.firestore.admin.v1.Field.TtlConfig.State.UNRECOGNIZED + : result; + } + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.Field.TtlConfig.State value) { + if (value == null) { + throw new NullPointerException(); + } + + state_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + + state_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Field.TtlConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Field.TtlConfig) + private static final com.google.firestore.admin.v1.Field.TtlConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Field.TtlConfig(); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TtlConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TtlConfig(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Required. A field name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * A field path may be a simple field name, e.g. `address` or a path to fields
+   * within map_value , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   * Field paths may be quoted using ` (backtick). The only character that needs
+   * to be escaped within a quoted field path is the backtick character itself,
+   * escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * ``` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   * Examples:
+   * (Note: Comments here are written in markdown syntax, so there is an
+   *  additional layer of backticks to represent a code block)
+   * `\`address.city\`` represents a field named `address.city`, not the map key
+   * `city` in the field `address`.
+   * `\`*\`` represents a field named `*`, not any field.
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. A field name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * A field path may be a simple field name, e.g. `address` or a path to fields
+   * within map_value , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   * Field paths may be quoted using ` (backtick). The only character that needs
+   * to be escaped within a quoted field path is the backtick character itself,
+   * escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * ``` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   * Examples:
+   * (Note: Comments here are written in markdown syntax, so there is an
+   *  additional layer of backticks to represent a code block)
+   * `\`address.city\`` represents a field named `address.city`, not the map key
+   * `city` in the field `address`.
+   * `\`*\`` represents a field named `*`, not any field.
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_CONFIG_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.Field.IndexConfig indexConfig_; + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return Whether the indexConfig field is set. + */ + @java.lang.Override + public boolean hasIndexConfig() { + return indexConfig_ != null; + } + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return The indexConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig getIndexConfig() { + return indexConfig_ == null + ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() + : indexConfig_; + } + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder() { + return getIndexConfig(); + } + + public static final int TTL_CONFIG_FIELD_NUMBER = 3; + private com.google.firestore.admin.v1.Field.TtlConfig ttlConfig_; + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + @java.lang.Override + public boolean hasTtlConfig() { + return ttlConfig_ != null; + } + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig() { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder() { + return getTtlConfig(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (indexConfig_ != null) { + output.writeMessage(2, getIndexConfig()); + } + if (ttlConfig_ != null) { + output.writeMessage(3, getTtlConfig()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (indexConfig_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndexConfig()); + } + if (ttlConfig_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getTtlConfig()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; @@ -1794,6 +2719,10 @@ public boolean equals(final java.lang.Object obj) { if (hasIndexConfig()) { if (!getIndexConfig().equals(other.getIndexConfig())) return false; } + if (hasTtlConfig() != other.hasTtlConfig()) return false; + if (hasTtlConfig()) { + if (!getTtlConfig().equals(other.getTtlConfig())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1811,6 +2740,10 @@ public int hashCode() { hash = (37 * hash) + INDEX_CONFIG_FIELD_NUMBER; hash = (53 * hash) + getIndexConfig().hashCode(); } + if (hasTtlConfig()) { + hash = (37 * hash) + TTL_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getTtlConfig().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1965,6 +2898,12 @@ public Builder clear() { indexConfig_ = null; indexConfigBuilder_ = null; } + if (ttlConfigBuilder_ == null) { + ttlConfig_ = null; + } else { + ttlConfig_ = null; + ttlConfigBuilder_ = null; + } return this; } @@ -1997,6 +2936,11 @@ public com.google.firestore.admin.v1.Field buildPartial() { } else { result.indexConfig_ = indexConfigBuilder_.build(); } + if (ttlConfigBuilder_ == null) { + result.ttlConfig_ = ttlConfig_; + } else { + result.ttlConfig_ = ttlConfigBuilder_.build(); + } onBuilt(); return result; } @@ -2053,6 +2997,9 @@ public Builder mergeFrom(com.google.firestore.admin.v1.Field other) { if (other.hasIndexConfig()) { mergeIndexConfig(other.getIndexConfig()); } + if (other.hasTtlConfig()) { + mergeTtlConfig(other.getTtlConfig()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -2506,6 +3453,210 @@ public com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOr return indexConfigBuilder_; } + private com.google.firestore.admin.v1.Field.TtlConfig ttlConfig_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder> + ttlConfigBuilder_; + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + public boolean hasTtlConfig() { + return ttlConfigBuilder_ != null || ttlConfig_ != null; + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + public com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig() { + if (ttlConfigBuilder_ == null) { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } else { + return ttlConfigBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder setTtlConfig(com.google.firestore.admin.v1.Field.TtlConfig value) { + if (ttlConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ttlConfig_ = value; + onChanged(); + } else { + ttlConfigBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder setTtlConfig( + com.google.firestore.admin.v1.Field.TtlConfig.Builder builderForValue) { + if (ttlConfigBuilder_ == null) { + ttlConfig_ = builderForValue.build(); + onChanged(); + } else { + ttlConfigBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder mergeTtlConfig(com.google.firestore.admin.v1.Field.TtlConfig value) { + if (ttlConfigBuilder_ == null) { + if (ttlConfig_ != null) { + ttlConfig_ = + com.google.firestore.admin.v1.Field.TtlConfig.newBuilder(ttlConfig_) + .mergeFrom(value) + .buildPartial(); + } else { + ttlConfig_ = value; + } + onChanged(); + } else { + ttlConfigBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder clearTtlConfig() { + if (ttlConfigBuilder_ == null) { + ttlConfig_ = null; + onChanged(); + } else { + ttlConfig_ = null; + ttlConfigBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public com.google.firestore.admin.v1.Field.TtlConfig.Builder getTtlConfigBuilder() { + + onChanged(); + return getTtlConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder() { + if (ttlConfigBuilder_ != null) { + return ttlConfigBuilder_.getMessageOrBuilder(); + } else { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } + } + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder> + getTtlConfigFieldBuilder() { + if (ttlConfigBuilder_ == null) { + ttlConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder>( + getTtlConfig(), getParentForChildren(), isClean()); + ttlConfig_ = null; + } + return ttlConfigBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java index 17dcd658f..bad3d033d 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java @@ -163,6 +163,24 @@ private FieldOperationMetadata( progressBytes_ = subBuilder.buildPartial(); } + break; + } + case 66: + { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder + subBuilder = null; + if (ttlConfigDelta_ != null) { + subBuilder = ttlConfigDelta_.toBuilder(); + } + ttlConfigDelta_ = + input.readMessage( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(ttlConfigDelta_); + ttlConfigDelta_ = subBuilder.buildPartial(); + } + break; } default: @@ -1219,76 +1237,909 @@ public Builder mergeIndex(com.google.firestore.admin.v1.Index value) { * * *
-       * The index being changed.
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public Builder clearIndex() { + if (indexBuilder_ == null) { + index_ = null; + onChanged(); + } else { + index_ = null; + indexBuilder_ = null; + } + + return this; + } + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public com.google.firestore.admin.v1.Index.Builder getIndexBuilder() { + + onChanged(); + return getIndexFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + if (indexBuilder_ != null) { + return indexBuilder_.getMessageOrBuilder(); + } else { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + } + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + getIndexFieldBuilder() { + if (indexBuilder_ == null) { + indexBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder>( + getIndex(), getParentForChildren(), isClean()); + index_ = null; + } + return indexBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + private static final com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta(); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexConfigDelta parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new IndexConfigDelta(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface TtlConfigDeltaOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + int getChangeTypeValue(); + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType getChangeType(); + } + /** + * + * + *
+   * Information about an TTL configuration change.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta} + */ + public static final class TtlConfigDelta extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + TtlConfigDeltaOrBuilder { + private static final long serialVersionUID = 0L; + // Use TtlConfigDelta.newBuilder() to construct. + private TtlConfigDelta(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TtlConfigDelta() { + changeType_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TtlConfigDelta(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private TtlConfigDelta( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + int rawValue = input.readEnum(); + + changeType_ = rawValue; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder.class); + } + + /** + * + * + *
+     * Specifies how the TTL config is changing.
+     * 
+ * + * Protobuf enum {@code + * google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType} + */ + public enum ChangeType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + CHANGE_TYPE_UNSPECIFIED(0), + /** + * + * + *
+       * The TTL config is being added.
+       * 
+ * + * ADD = 1; + */ + ADD(1), + /** + * + * + *
+       * The TTL config is being removed.
+       * 
+ * + * REMOVE = 2; + */ + REMOVE(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + public static final int CHANGE_TYPE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+       * The TTL config is being added.
+       * 
+ * + * ADD = 1; + */ + public static final int ADD_VALUE = 1; + /** + * + * + *
+       * The TTL config is being removed.
+       * 
+ * + * REMOVE = 2; + */ + public static final int REMOVE_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ChangeType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ChangeType forNumber(int value) { + switch (value) { + case 0: + return CHANGE_TYPE_UNSPECIFIED; + case 1: + return ADD; + case 2: + return REMOVE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ChangeType findValueByNumber(int number) { + return ChangeType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final ChangeType[] VALUES = values(); + + public static ChangeType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ChangeType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType) + } + + public static final int CHANGE_TYPE_FIELD_NUMBER = 1; + private int changeType_; + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + getChangeType() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType.valueOf( + changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, changeType_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, changeType_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta other = + (com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) obj; + + if (changeType_ != other.changeType_) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CHANGE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + changeType_; + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * Information about an TTL configuration change.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + changeType_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta build() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta buildPartial() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta result = + new com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta(this); + result.changeType_ = changeType_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) { + return mergeFrom( + (com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta other) { + if (other + == com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance()) return this; + if (other.changeType_ != 0) { + setChangeTypeValue(other.getChangeTypeValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int changeType_ = 0; + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
        * 
* - * .google.firestore.admin.v1.Index index = 2; + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @param value The enum numeric value on the wire for changeType to set. + * @return This builder for chaining. */ - public Builder clearIndex() { - if (indexBuilder_ == null) { - index_ = null; - onChanged(); - } else { - index_ = null; - indexBuilder_ = null; - } + public Builder setChangeTypeValue(int value) { + changeType_ = value; + onChanged(); return this; } /** * * *
-       * The index being changed.
+       * Specifies how the TTL configuration is changing.
        * 
* - * .google.firestore.admin.v1.Index index = 2; + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. */ - public com.google.firestore.admin.v1.Index.Builder getIndexBuilder() { - - onChanged(); - return getIndexFieldBuilder().getBuilder(); + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + getChangeType() { + @SuppressWarnings("deprecation") + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType.valueOf( + changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .UNRECOGNIZED + : result; } /** * * *
-       * The index being changed.
+       * Specifies how the TTL configuration is changing.
        * 
* - * .google.firestore.admin.v1.Index index = 2; + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @param value The changeType to set. + * @return This builder for chaining. */ - public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { - if (indexBuilder_ != null) { - return indexBuilder_.getMessageOrBuilder(); - } else { - return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + public Builder setChangeType( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType value) { + if (value == null) { + throw new NullPointerException(); } + + changeType_ = value.getNumber(); + onChanged(); + return this; } /** * * *
-       * The index being changed.
+       * Specifies how the TTL configuration is changing.
        * 
* - * .google.firestore.admin.v1.Index index = 2; + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return This builder for chaining. */ - private com.google.protobuf.SingleFieldBuilderV3< - com.google.firestore.admin.v1.Index, - com.google.firestore.admin.v1.Index.Builder, - com.google.firestore.admin.v1.IndexOrBuilder> - getIndexFieldBuilder() { - if (indexBuilder_ == null) { - indexBuilder_ = - new com.google.protobuf.SingleFieldBuilderV3< - com.google.firestore.admin.v1.Index, - com.google.firestore.admin.v1.Index.Builder, - com.google.firestore.admin.v1.IndexOrBuilder>( - getIndex(), getParentForChildren(), isClean()); - index_ = null; - } - return indexBuilder_; + public Builder clearChangeType() { + + changeType_ = 0; + onChanged(); + return this; } @java.lang.Override @@ -1303,45 +2154,44 @@ public final Builder mergeUnknownFields( return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) } - // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) - private static final com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + private static final com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = - new com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta(); + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta(); } - public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { @java.lang.Override - public IndexConfigDelta parsePartialFrom( + public TtlConfigDelta parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return new IndexConfigDelta(input, extensionRegistry); + return new TtlConfigDelta(input, extensionRegistry); } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override - public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getDefaultInstanceForType() { return DEFAULT_INSTANCE; } @@ -1714,6 +2564,58 @@ public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder return getProgressBytes(); } + public static final int TTL_CONFIG_DELTA_FIELD_NUMBER = 8; + private com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttlConfigDelta_; + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + @java.lang.Override + public boolean hasTtlConfigDelta() { + return ttlConfigDelta_ != null; + } + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta() { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.getDefaultInstance() + : ttlConfigDelta_; + } + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder() { + return getTtlConfigDelta(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1750,6 +2652,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (progressBytes_ != null) { output.writeMessage(7, getProgressBytes()); } + if (ttlConfigDelta_ != null) { + output.writeMessage(8, getTtlConfigDelta()); + } unknownFields.writeTo(output); } @@ -1782,6 +2687,9 @@ public int getSerializedSize() { if (progressBytes_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getProgressBytes()); } + if (ttlConfigDelta_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getTtlConfigDelta()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1817,6 +2725,10 @@ public boolean equals(final java.lang.Object obj) { if (hasProgressBytes()) { if (!getProgressBytes().equals(other.getProgressBytes())) return false; } + if (hasTtlConfigDelta() != other.hasTtlConfigDelta()) return false; + if (hasTtlConfigDelta()) { + if (!getTtlConfigDelta().equals(other.getTtlConfigDelta())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1852,6 +2764,10 @@ public int hashCode() { hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; hash = (53 * hash) + getProgressBytes().hashCode(); } + if (hasTtlConfigDelta()) { + hash = (37 * hash) + TTL_CONFIG_DELTA_FIELD_NUMBER; + hash = (53 * hash) + getTtlConfigDelta().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -2034,6 +2950,12 @@ public Builder clear() { progressBytes_ = null; progressBytesBuilder_ = null; } + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDelta_ = null; + } else { + ttlConfigDelta_ = null; + ttlConfigDeltaBuilder_ = null; + } return this; } @@ -2093,6 +3015,11 @@ public com.google.firestore.admin.v1.FieldOperationMetadata buildPartial() { } else { result.progressBytes_ = progressBytesBuilder_.build(); } + if (ttlConfigDeltaBuilder_ == null) { + result.ttlConfigDelta_ = ttlConfigDelta_; + } else { + result.ttlConfigDelta_ = ttlConfigDeltaBuilder_.build(); + } onBuilt(); return result; } @@ -2189,6 +3116,9 @@ public Builder mergeFrom(com.google.firestore.admin.v1.FieldOperationMetadata ot if (other.hasProgressBytes()) { mergeProgressBytes(other.getProgressBytes()); } + if (other.hasTtlConfigDelta()) { + mergeTtlConfigDelta(other.getTtlConfigDelta()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -3596,6 +4526,209 @@ public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder return progressBytesBuilder_; } + private com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttlConfigDelta_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder> + ttlConfigDeltaBuilder_; + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + public boolean hasTtlConfigDelta() { + return ttlConfigDeltaBuilder_ != null || ttlConfigDelta_ != null; + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta() { + if (ttlConfigDeltaBuilder_ == null) { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance() + : ttlConfigDelta_; + } else { + return ttlConfigDeltaBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder setTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta value) { + if (ttlConfigDeltaBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ttlConfigDelta_ = value; + onChanged(); + } else { + ttlConfigDeltaBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder setTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder + builderForValue) { + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDelta_ = builderForValue.build(); + onChanged(); + } else { + ttlConfigDeltaBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder mergeTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta value) { + if (ttlConfigDeltaBuilder_ == null) { + if (ttlConfigDelta_ != null) { + ttlConfigDelta_ = + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.newBuilder( + ttlConfigDelta_) + .mergeFrom(value) + .buildPartial(); + } else { + ttlConfigDelta_ = value; + } + onChanged(); + } else { + ttlConfigDeltaBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder clearTtlConfigDelta() { + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDelta_ = null; + onChanged(); + } else { + ttlConfigDelta_ = null; + ttlConfigDeltaBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder + getTtlConfigDeltaBuilder() { + + onChanged(); + return getTtlConfigDeltaFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder() { + if (ttlConfigDeltaBuilder_ != null) { + return ttlConfigDeltaBuilder_.getMessageOrBuilder(); + } else { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance() + : ttlConfigDelta_; + } + } + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder> + getTtlConfigDeltaFieldBuilder() { + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDeltaBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder>( + getTtlConfigDelta(), getParentForChildren(), isClean()); + ttlConfigDelta_ = null; + } + return ttlConfigDeltaBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java index 1943dcea9..0af121235 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java @@ -288,4 +288,43 @@ com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta getIndexCo * .google.firestore.admin.v1.Progress progress_bytes = 7; */ com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + boolean hasTtlConfigDelta(); + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta(); + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder(); } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java index 957cb5b17..10f855658 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java @@ -133,4 +133,45 @@ public interface FieldOrBuilder * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; */ com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder(); + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + boolean hasTtlConfig(); + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig(); + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder(); } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java index 72178f591..5fcc0320a 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java @@ -35,6 +35,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_Field_IndexConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -48,22 +52,27 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\031google.firestore.admin.v1\032\037google/api/f" + "ield_behavior.proto\032\031google/api/resource" + ".proto\032%google/firestore/admin/v1/index." - + "proto\032\034google/api/annotations.proto\"\345\002\n\005" - + "Field\022\021\n\004name\030\001 \001(\tB\003\340A\002\022B\n\014index_config" - + "\030\002 \001(\0132,.google.firestore.admin.v1.Field" - + ".IndexConfig\032\211\001\n\013IndexConfig\0221\n\007indexes\030" - + "\001 \003(\0132 .google.firestore.admin.v1.Index\022" - + "\034\n\024uses_ancestor_config\030\002 \001(\010\022\026\n\016ancesto" - + "r_field\030\003 \001(\t\022\021\n\treverting\030\004 \001(\010:y\352Av\n\036f" - + "irestore.googleapis.com/Field\022Tprojects/" - + "{project}/databases/{database}/collectio" - + "nGroups/{collection}/fields/{field}B\336\001\n\035" - + "com.google.firestore.admin.v1B\nFieldProt" - + "oP\001Z>google.golang.org/genproto/googleap" - + "is/firestore/admin/v1;admin\242\002\004GCFS\252\002\037Goo" - + "gle.Cloud.Firestore.Admin.V1\312\002\037Google\\Cl" - + "oud\\Firestore\\Admin\\V1\352\002#Google::Cloud::" - + "Firestore::Admin::V1b\006proto3" + + "proto\"\305\004\n\005Field\022\021\n\004name\030\001 \001(\tB\003\340A\002\022B\n\014in" + + "dex_config\030\002 \001(\0132,.google.firestore.admi" + + "n.v1.Field.IndexConfig\022>\n\nttl_config\030\003 \001" + + "(\0132*.google.firestore.admin.v1.Field.Ttl" + + "Config\032\211\001\n\013IndexConfig\0221\n\007indexes\030\001 \003(\0132" + + " .google.firestore.admin.v1.Index\022\034\n\024use" + + "s_ancestor_config\030\002 \001(\010\022\026\n\016ancestor_fiel" + + "d\030\003 \001(\t\022\021\n\treverting\030\004 \001(\010\032\235\001\n\tTtlConfig" + + "\022D\n\005state\030\001 \001(\01620.google.firestore.admin" + + ".v1.Field.TtlConfig.StateB\003\340A\003\"J\n\005State\022" + + "\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\n\n\006" + + "ACTIVE\020\002\022\020\n\014NEEDS_REPAIR\020\003:y\352Av\n\036firesto" + + "re.googleapis.com/Field\022Tprojects/{proje" + + "ct}/databases/{database}/collectionGroup" + + "s/{collection}/fields/{field}B\336\001\n\035com.go" + + "ogle.firestore.admin.v1B\nFieldProtoP\001Z>g" + + "oogle.golang.org/genproto/googleapis/fir" + + "estore/admin/v1;admin\242\002\004GCFS\252\002\037Google.Cl" + + "oud.Firestore.Admin.V1\312\002\037Google\\Cloud\\Fi" + + "restore\\Admin\\V1\352\002#Google::Cloud::Firest" + + "ore::Admin::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -72,7 +81,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.FieldBehaviorProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), com.google.firestore.admin.v1.IndexProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_Field_descriptor = getDescriptor().getMessageTypes().get(0); @@ -80,7 +88,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_Field_descriptor, new java.lang.String[] { - "Name", "IndexConfig", + "Name", "IndexConfig", "TtlConfig", }); internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor = internal_static_google_firestore_admin_v1_Field_descriptor.getNestedTypes().get(0); @@ -90,6 +98,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Indexes", "UsesAncestorConfig", "AncestorField", "Reverting", }); + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor = + internal_static_google_firestore_admin_v1_Field_descriptor.getNestedTypes().get(1); + internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor, + new java.lang.String[] { + "State", + }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); @@ -99,7 +115,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.FieldBehaviorProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); com.google.firestore.admin.v1.IndexProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java index e2e7c708c..a607b4a0c 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java @@ -107,125 +107,123 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "roto\032\031google/api/resource.proto\032(google/" + "firestore/admin/v1/database.proto\032%googl" + "e/firestore/admin/v1/field.proto\032%google" - + "/firestore/admin/v1/index.proto\032)google/" - + "firestore/admin/v1/operation.proto\032#goog" - + "le/longrunning/operations.proto\032\033google/" - + "protobuf/empty.proto\032 google/protobuf/fi" - + "eld_mask.proto\032\037google/protobuf/timestam" - + "p.proto\"Q\n\024ListDatabasesRequest\0229\n\006paren" - + "t\030\001 \001(\tB)\340A\002\372A#\022!firestore.googleapis.co" - + "m/Database\"O\n\025ListDatabasesResponse\0226\n\td" - + "atabases\030\001 \003(\0132#.google.firestore.admin." - + "v1.Database\"M\n\022GetDatabaseRequest\0227\n\004nam" - + "e\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleapis.co" - + "m/Database\"\204\001\n\025UpdateDatabaseRequest\022:\n\010" - + "database\030\001 \001(\0132#.google.firestore.admin." - + "v1.DatabaseB\003\340A\002\022/\n\013update_mask\030\002 \001(\0132\032." - + "google.protobuf.FieldMask\"\030\n\026UpdateDatab" - + "aseMetadata\"\214\001\n\022CreateIndexRequest\022@\n\006pa" - + "rent\030\001 \001(\tB0\340A\002\372A*\n(firestore.googleapis" - + ".com/CollectionGroup\0224\n\005index\030\002 \001(\0132 .go" - + "ogle.firestore.admin.v1.IndexB\003\340A\002\"\215\001\n\022L" - + "istIndexesRequest\022@\n\006parent\030\001 \001(\tB0\340A\002\372A" - + "*\n(firestore.googleapis.com/CollectionGr" - + "oup\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022" - + "\n\npage_token\030\004 \001(\t\"a\n\023ListIndexesRespons" - + "e\0221\n\007indexes\030\001 \003(\0132 .google.firestore.ad" - + "min.v1.Index\022\027\n\017next_page_token\030\002 \001(\t\"G\n" - + "\017GetIndexRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036" - + "firestore.googleapis.com/Index\"J\n\022Delete" - + "IndexRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036fire" - + "store.googleapis.com/Index\"{\n\022UpdateFiel" - + "dRequest\0224\n\005field\030\001 \001(\0132 .google.firesto" - + "re.admin.v1.FieldB\003\340A\002\022/\n\013update_mask\030\002 " - + "\001(\0132\032.google.protobuf.FieldMask\"G\n\017GetFi" - + "eldRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036firest" - + "ore.googleapis.com/Field\"\214\001\n\021ListFieldsR" - + "equest\022@\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(firestor" - + "e.googleapis.com/CollectionGroup\022\016\n\006filt" - + "er\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_toke" - + "n\030\004 \001(\t\"_\n\022ListFieldsResponse\0220\n\006fields\030" - + "\001 \003(\0132 .google.firestore.admin.v1.Field\022" - + "\027\n\017next_page_token\030\002 \001(\t\"\204\001\n\026ExportDocum" - + "entsRequest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!fires" - + "tore.googleapis.com/Database\022\026\n\016collecti" - + "on_ids\030\002 \003(\t\022\031\n\021output_uri_prefix\030\003 \001(\t\"" - + "\203\001\n\026ImportDocumentsRequest\0227\n\004name\030\001 \001(\t" - + "B)\340A\002\372A#\n!firestore.googleapis.com/Datab" - + "ase\022\026\n\016collection_ids\030\002 \003(\t\022\030\n\020input_uri" - + "_prefix\030\003 \001(\t2\222\023\n\016FirestoreAdmin\022\333\001\n\013Cre" - + "ateIndex\022-.google.firestore.admin.v1.Cre" - + "ateIndexRequest\032\035.google.longrunning.Ope" - + "ration\"~\202\323\344\223\002G\">/v1/{parent=projects/*/d" - + "atabases/*/collectionGroups/*}/indexes:\005" - + "index\332A\014parent,index\312A\037\n\005Index\022\026IndexOpe" - + "rationMetadata\022\275\001\n\013ListIndexes\022-.google." - + "firestore.admin.v1.ListIndexesRequest\032.." - + "google.firestore.admin.v1.ListIndexesRes" - + "ponse\"O\202\323\344\223\002@\022>/v1/{parent=projects/*/da" - + "tabases/*/collectionGroups/*}/indexes\332A\006" - + "parent\022\247\001\n\010GetIndex\022*.google.firestore.a" - + "dmin.v1.GetIndexRequest\032 .google.firesto" - + "re.admin.v1.Index\"M\202\323\344\223\002@\022>/v1/{name=pro" - + "jects/*/databases/*/collectionGroups/*/i" - + "ndexes/*}\332A\004name\022\243\001\n\013DeleteIndex\022-.googl" - + "e.firestore.admin.v1.DeleteIndexRequest\032" - + "\026.google.protobuf.Empty\"M\202\323\344\223\002@*>/v1/{na" - + "me=projects/*/databases/*/collectionGrou" - + "ps/*/indexes/*}\332A\004name\022\246\001\n\010GetField\022*.go" - + "ogle.firestore.admin.v1.GetFieldRequest\032" - + " .google.firestore.admin.v1.Field\"L\202\323\344\223\002" - + "?\022=/v1/{name=projects/*/databases/*/coll" - + "ectionGroups/*/fields/*}\332A\004name\022\331\001\n\013Upda" - + "teField\022-.google.firestore.admin.v1.Upda" - + "teFieldRequest\032\035.google.longrunning.Oper" - + "ation\"|\202\323\344\223\002L2C/v1/{field.name=projects/" - + "*/databases/*/collectionGroups/*/fields/" - + "*}:\005field\332A\005field\312A\037\n\005Field\022\026FieldOperat" - + "ionMetadata\022\271\001\n\nListFields\022,.google.fire" - + "store.admin.v1.ListFieldsRequest\032-.googl" - + "e.firestore.admin.v1.ListFieldsResponse\"" - + "N\202\323\344\223\002?\022=/v1/{parent=projects/*/database" - + "s/*/collectionGroups/*}/fields\332A\006parent\022" - + "\335\001\n\017ExportDocuments\0221.google.firestore.a" - + "dmin.v1.ExportDocumentsRequest\032\035.google." - + "longrunning.Operation\"x\202\323\344\223\0026\"1/v1/{name" - + "=projects/*/databases/*}:exportDocuments" - + ":\001*\332A\004name\312A2\n\027ExportDocumentsResponse\022\027" - + "ExportDocumentsMetadata\022\333\001\n\017ImportDocume" - + "nts\0221.google.firestore.admin.v1.ImportDo" - + "cumentsRequest\032\035.google.longrunning.Oper" - + "ation\"v\202\323\344\223\0026\"1/v1/{name=projects/*/data" - + "bases/*}:importDocuments:\001*\332A\004name\312A0\n\025g" - + "oogle.protobuf.Empty\022\027ImportDocumentsMet" - + "adata\022\223\001\n\013GetDatabase\022-.google.firestore" - + ".admin.v1.GetDatabaseRequest\032#.google.fi" - + "restore.admin.v1.Database\"0\202\323\344\223\002#\022!/v1/{" - + "name=projects/*/databases/*}\332A\004name\022\246\001\n\r" - + "ListDatabases\022/.google.firestore.admin.v" - + "1.ListDatabasesRequest\0320.google.firestor" - + "e.admin.v1.ListDatabasesResponse\"2\202\323\344\223\002#" - + "\022!/v1/{parent=projects/*}/databases\332A\006pa" - + "rent\022\333\001\n\016UpdateDatabase\0220.google.firesto" - + "re.admin.v1.UpdateDatabaseRequest\032\035.goog" - + "le.longrunning.Operation\"x\202\323\344\223\00262*/v1/{d" - + "atabase.name=projects/*/databases/*}:\010da" - + "tabase\332A\024database,update_mask\312A\"\n\010Databa" - + "se\022\026UpdateDatabaseMetadata\032v\312A\030firestore" - + ".googleapis.com\322AXhttps://www.googleapis" - + ".com/auth/cloud-platform,https://www.goo" - + "gleapis.com/auth/datastoreB\252\003\n\035com.googl" - + "e.firestore.admin.v1B\023FirestoreAdminProt" - + "oP\001Z>google.golang.org/genproto/googleap" - + "is/firestore/admin/v1;admin\242\002\004GCFS\252\002\037Goo" - + "gle.Cloud.Firestore.Admin.V1\312\002\037Google\\Cl" - + "oud\\Firestore\\Admin\\V1\352\002#Google::Cloud::" - + "Firestore::Admin::V1\352AL\n!firestore.googl" - + "eapis.com/Location\022\'projects/{project}/l" - + "ocations/{location}\352Aq\n(firestore.google" - + "apis.com/CollectionGroup\022Eprojects/{proj" - + "ect}/databases/{database}/collectionGrou" - + "ps/{collection}b\006proto3" + + "/firestore/admin/v1/index.proto\032#google/" + + "longrunning/operations.proto\032\033google/pro" + + "tobuf/empty.proto\032 google/protobuf/field" + + "_mask.proto\"Q\n\024ListDatabasesRequest\0229\n\006p" + + "arent\030\001 \001(\tB)\340A\002\372A#\022!firestore.googleapi" + + "s.com/Database\"O\n\025ListDatabasesResponse\022" + + "6\n\tdatabases\030\001 \003(\0132#.google.firestore.ad" + + "min.v1.Database\"M\n\022GetDatabaseRequest\0227\n" + + "\004name\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleapi" + + "s.com/Database\"\204\001\n\025UpdateDatabaseRequest" + + "\022:\n\010database\030\001 \001(\0132#.google.firestore.ad" + + "min.v1.DatabaseB\003\340A\002\022/\n\013update_mask\030\002 \001(" + + "\0132\032.google.protobuf.FieldMask\"\030\n\026UpdateD" + + "atabaseMetadata\"\214\001\n\022CreateIndexRequest\022@" + + "\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(firestore.google" + + "apis.com/CollectionGroup\0224\n\005index\030\002 \001(\0132" + + " .google.firestore.admin.v1.IndexB\003\340A\002\"\215" + + "\001\n\022ListIndexesRequest\022@\n\006parent\030\001 \001(\tB0\340" + + "A\002\372A*\n(firestore.googleapis.com/Collecti" + + "onGroup\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001" + + "(\005\022\022\n\npage_token\030\004 \001(\t\"a\n\023ListIndexesRes" + + "ponse\0221\n\007indexes\030\001 \003(\0132 .google.firestor" + + "e.admin.v1.Index\022\027\n\017next_page_token\030\002 \001(" + + "\t\"G\n\017GetIndexRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372" + + "A \n\036firestore.googleapis.com/Index\"J\n\022De" + + "leteIndexRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036" + + "firestore.googleapis.com/Index\"{\n\022Update" + + "FieldRequest\0224\n\005field\030\001 \001(\0132 .google.fir" + + "estore.admin.v1.FieldB\003\340A\002\022/\n\013update_mas" + + "k\030\002 \001(\0132\032.google.protobuf.FieldMask\"G\n\017G" + + "etFieldRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036fi" + + "restore.googleapis.com/Field\"\214\001\n\021ListFie" + + "ldsRequest\022@\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(fire" + + "store.googleapis.com/CollectionGroup\022\016\n\006" + + "filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_" + + "token\030\004 \001(\t\"_\n\022ListFieldsResponse\0220\n\006fie" + + "lds\030\001 \003(\0132 .google.firestore.admin.v1.Fi" + + "eld\022\027\n\017next_page_token\030\002 \001(\t\"\204\001\n\026ExportD" + + "ocumentsRequest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!f" + + "irestore.googleapis.com/Database\022\026\n\016coll" + + "ection_ids\030\002 \003(\t\022\031\n\021output_uri_prefix\030\003 " + + "\001(\t\"\203\001\n\026ImportDocumentsRequest\0227\n\004name\030\001" + + " \001(\tB)\340A\002\372A#\n!firestore.googleapis.com/D" + + "atabase\022\026\n\016collection_ids\030\002 \003(\t\022\030\n\020input" + + "_uri_prefix\030\003 \001(\t2\222\023\n\016FirestoreAdmin\022\333\001\n" + + "\013CreateIndex\022-.google.firestore.admin.v1" + + ".CreateIndexRequest\032\035.google.longrunning" + + ".Operation\"~\202\323\344\223\002G\">/v1/{parent=projects" + + "/*/databases/*/collectionGroups/*}/index" + + "es:\005index\332A\014parent,index\312A\037\n\005Index\022\026Inde" + + "xOperationMetadata\022\275\001\n\013ListIndexes\022-.goo" + + "gle.firestore.admin.v1.ListIndexesReques" + + "t\032..google.firestore.admin.v1.ListIndexe" + + "sResponse\"O\202\323\344\223\002@\022>/v1/{parent=projects/" + + "*/databases/*/collectionGroups/*}/indexe" + + "s\332A\006parent\022\247\001\n\010GetIndex\022*.google.firesto" + + "re.admin.v1.GetIndexRequest\032 .google.fir" + + "estore.admin.v1.Index\"M\202\323\344\223\002@\022>/v1/{name" + + "=projects/*/databases/*/collectionGroups" + + "/*/indexes/*}\332A\004name\022\243\001\n\013DeleteIndex\022-.g" + + "oogle.firestore.admin.v1.DeleteIndexRequ" + + "est\032\026.google.protobuf.Empty\"M\202\323\344\223\002@*>/v1" + + "/{name=projects/*/databases/*/collection" + + "Groups/*/indexes/*}\332A\004name\022\246\001\n\010GetField\022" + + "*.google.firestore.admin.v1.GetFieldRequ" + + "est\032 .google.firestore.admin.v1.Field\"L\202" + + "\323\344\223\002?\022=/v1/{name=projects/*/databases/*/" + + "collectionGroups/*/fields/*}\332A\004name\022\331\001\n\013" + + "UpdateField\022-.google.firestore.admin.v1." + + "UpdateFieldRequest\032\035.google.longrunning." + + "Operation\"|\202\323\344\223\002L2C/v1/{field.name=proje" + + "cts/*/databases/*/collectionGroups/*/fie" + + "lds/*}:\005field\332A\005field\312A\037\n\005Field\022\026FieldOp" + + "erationMetadata\022\271\001\n\nListFields\022,.google." + + "firestore.admin.v1.ListFieldsRequest\032-.g" + + "oogle.firestore.admin.v1.ListFieldsRespo" + + "nse\"N\202\323\344\223\002?\022=/v1/{parent=projects/*/data" + + "bases/*/collectionGroups/*}/fields\332A\006par" + + "ent\022\335\001\n\017ExportDocuments\0221.google.firesto" + + "re.admin.v1.ExportDocumentsRequest\032\035.goo" + + "gle.longrunning.Operation\"x\202\323\344\223\0026\"1/v1/{" + + "name=projects/*/databases/*}:exportDocum" + + "ents:\001*\332A\004name\312A2\n\027ExportDocumentsRespon" + + "se\022\027ExportDocumentsMetadata\022\333\001\n\017ImportDo" + + "cuments\0221.google.firestore.admin.v1.Impo" + + "rtDocumentsRequest\032\035.google.longrunning." + + "Operation\"v\202\323\344\223\0026\"1/v1/{name=projects/*/" + + "databases/*}:importDocuments:\001*\332A\004name\312A" + + "0\n\025google.protobuf.Empty\022\027ImportDocument" + + "sMetadata\022\223\001\n\013GetDatabase\022-.google.fires" + + "tore.admin.v1.GetDatabaseRequest\032#.googl" + + "e.firestore.admin.v1.Database\"0\202\323\344\223\002#\022!/" + + "v1/{name=projects/*/databases/*}\332A\004name\022" + + "\246\001\n\rListDatabases\022/.google.firestore.adm" + + "in.v1.ListDatabasesRequest\0320.google.fire" + + "store.admin.v1.ListDatabasesResponse\"2\202\323" + + "\344\223\002#\022!/v1/{parent=projects/*}/databases\332" + + "A\006parent\022\333\001\n\016UpdateDatabase\0220.google.fir" + + "estore.admin.v1.UpdateDatabaseRequest\032\035." + + "google.longrunning.Operation\"x\202\323\344\223\00262*/v" + + "1/{database.name=projects/*/databases/*}" + + ":\010database\332A\024database,update_mask\312A\"\n\010Da" + + "tabase\022\026UpdateDatabaseMetadata\032v\312A\030fires" + + "tore.googleapis.com\322AXhttps://www.google" + + "apis.com/auth/cloud-platform,https://www" + + ".googleapis.com/auth/datastoreB\252\003\n\035com.g" + + "oogle.firestore.admin.v1B\023FirestoreAdmin" + + "ProtoP\001Z>google.golang.org/genproto/goog" + + "leapis/firestore/admin/v1;admin\242\002\004GCFS\252\002" + + "\037Google.Cloud.Firestore.Admin.V1\312\002\037Googl" + + "e\\Cloud\\Firestore\\Admin\\V1\352\002#Google::Clo" + + "ud::Firestore::Admin::V1\352AL\n!firestore.g" + + "oogleapis.com/Location\022\'projects/{projec" + + "t}/locations/{location}\352Aq\n(firestore.go" + + "ogleapis.com/CollectionGroup\022Eprojects/{" + + "project}/databases/{database}/collection" + + "Groups/{collection}b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -238,11 +236,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.firestore.admin.v1.DatabaseProto.getDescriptor(), com.google.firestore.admin.v1.FieldProto.getDescriptor(), com.google.firestore.admin.v1.IndexProto.getDescriptor(), - com.google.firestore.admin.v1.OperationProto.getDescriptor(), com.google.longrunning.OperationsProto.getDescriptor(), com.google.protobuf.EmptyProto.getDescriptor(), com.google.protobuf.FieldMaskProto.getDescriptor(), - com.google.protobuf.TimestampProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor = getDescriptor().getMessageTypes().get(0); @@ -389,11 +385,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.firestore.admin.v1.DatabaseProto.getDescriptor(); com.google.firestore.admin.v1.FieldProto.getDescriptor(); com.google.firestore.admin.v1.IndexProto.getDescriptor(); - com.google.firestore.admin.v1.OperationProto.getDescriptor(); com.google.longrunning.OperationsProto.getDescriptor(); com.google.protobuf.EmptyProto.getDescriptor(); com.google.protobuf.FieldMaskProto.getDescriptor(); - com.google.protobuf.TimestampProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java index 5b80a6429..c30e16305 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java @@ -46,41 +46,39 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { java.lang.String[] descriptorData = { "\n%google/firestore/admin/v1/index.proto\022" + "\031google.firestore.admin.v1\032\031google/api/r" - + "esource.proto\032\034google/api/annotations.pr" - + "oto\"\243\006\n\005Index\022\014\n\004name\030\001 \001(\t\022@\n\013query_sco" - + "pe\030\002 \001(\0162+.google.firestore.admin.v1.Ind" - + "ex.QueryScope\022;\n\006fields\030\003 \003(\0132+.google.f" - + "irestore.admin.v1.Index.IndexField\0225\n\005st" - + "ate\030\004 \001(\0162&.google.firestore.admin.v1.In" - + "dex.State\032\275\002\n\nIndexField\022\022\n\nfield_path\030\001" - + " \001(\t\022B\n\005order\030\002 \001(\01621.google.firestore.a" - + "dmin.v1.Index.IndexField.OrderH\000\022O\n\014arra" - + "y_config\030\003 \001(\01627.google.firestore.admin." - + "v1.Index.IndexField.ArrayConfigH\000\"=\n\005Ord" - + "er\022\025\n\021ORDER_UNSPECIFIED\020\000\022\r\n\tASCENDING\020\001" - + "\022\016\n\nDESCENDING\020\002\"9\n\013ArrayConfig\022\034\n\030ARRAY" - + "_CONFIG_UNSPECIFIED\020\000\022\014\n\010CONTAINS\020\001B\014\n\nv" - + "alue_mode\"O\n\nQueryScope\022\033\n\027QUERY_SCOPE_U" - + "NSPECIFIED\020\000\022\016\n\nCOLLECTION\020\001\022\024\n\020COLLECTI" - + "ON_GROUP\020\002\"I\n\005State\022\025\n\021STATE_UNSPECIFIED" - + "\020\000\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002\022\020\n\014NEEDS_REP" - + "AIR\020\003:z\352Aw\n\036firestore.googleapis.com/Ind" - + "ex\022Uprojects/{project}/databases/{databa" - + "se}/collectionGroups/{collection}/indexe" - + "s/{index}B\336\001\n\035com.google.firestore.admin" - + ".v1B\nIndexProtoP\001Z>google.golang.org/gen" - + "proto/googleapis/firestore/admin/v1;admi" - + "n\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin." - + "V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#G" - + "oogle::Cloud::Firestore::Admin::V1b\006prot" - + "o3" + + "esource.proto\"\243\006\n\005Index\022\014\n\004name\030\001 \001(\t\022@\n" + + "\013query_scope\030\002 \001(\0162+.google.firestore.ad" + + "min.v1.Index.QueryScope\022;\n\006fields\030\003 \003(\0132" + + "+.google.firestore.admin.v1.Index.IndexF" + + "ield\0225\n\005state\030\004 \001(\0162&.google.firestore.a" + + "dmin.v1.Index.State\032\275\002\n\nIndexField\022\022\n\nfi" + + "eld_path\030\001 \001(\t\022B\n\005order\030\002 \001(\01621.google.f" + + "irestore.admin.v1.Index.IndexField.Order" + + "H\000\022O\n\014array_config\030\003 \001(\01627.google.firest" + + "ore.admin.v1.Index.IndexField.ArrayConfi" + + "gH\000\"=\n\005Order\022\025\n\021ORDER_UNSPECIFIED\020\000\022\r\n\tA" + + "SCENDING\020\001\022\016\n\nDESCENDING\020\002\"9\n\013ArrayConfi" + + "g\022\034\n\030ARRAY_CONFIG_UNSPECIFIED\020\000\022\014\n\010CONTA" + + "INS\020\001B\014\n\nvalue_mode\"O\n\nQueryScope\022\033\n\027QUE" + + "RY_SCOPE_UNSPECIFIED\020\000\022\016\n\nCOLLECTION\020\001\022\024" + + "\n\020COLLECTION_GROUP\020\002\"I\n\005State\022\025\n\021STATE_U" + + "NSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002\022\020\n" + + "\014NEEDS_REPAIR\020\003:z\352Aw\n\036firestore.googleap" + + "is.com/Index\022Uprojects/{project}/databas" + + "es/{database}/collectionGroups/{collecti" + + "on}/indexes/{index}B\336\001\n\035com.google.fires" + + "tore.admin.v1B\nIndexProtoP\001Z>google.gola" + + "ng.org/genproto/googleapis/firestore/adm" + + "in/v1;admin\242\002\004GCFS\252\002\037Google.Cloud.Firest" + + "ore.Admin.V1\312\002\037Google\\Cloud\\Firestore\\Ad" + + "min\\V1\352\002#Google::Cloud::Firestore::Admin" + + "::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { com.google.api.ResourceProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_Index_descriptor = getDescriptor().getMessageTypes().get(0); @@ -104,7 +102,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( descriptor, registry); com.google.api.ResourceProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java index deed9f3f9..be694b9a8 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java @@ -41,31 +41,24 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { static { java.lang.String[] descriptorData = { "\n(google/firestore/admin/v1/location.pro" - + "to\022\031google.firestore.admin.v1\032\030google/ty" - + "pe/latlng.proto\032\034google/api/annotations." - + "proto\"\022\n\020LocationMetadataB\341\001\n\035com.google" - + ".firestore.admin.v1B\rLocationProtoP\001Z>go" - + "ogle.golang.org/genproto/googleapis/fire" - + "store/admin/v1;admin\242\002\004GCFS\252\002\037Google.Clo" - + "ud.Firestore.Admin.V1\312\002\037Google\\Cloud\\Fir" - + "estore\\Admin\\V1\352\002#Google::Cloud::Firesto" - + "re::Admin::V1b\006proto3" + + "to\022\031google.firestore.admin.v1\"\022\n\020Locatio" + + "nMetadataB\341\001\n\035com.google.firestore.admin" + + ".v1B\rLocationProtoP\001Z>google.golang.org/" + + "genproto/googleapis/firestore/admin/v1;a" + + "dmin\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Adm" + + "in.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352" + + "\002#Google::Cloud::Firestore::Admin::V1b\006p" + + "roto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - com.google.type.LatLngProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), - }); + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); internal_static_google_firestore_admin_v1_LocationMetadata_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_firestore_admin_v1_LocationMetadata_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_LocationMetadata_descriptor, new java.lang.String[] {}); - com.google.type.LatLngProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java index 94c8e7e48..7c4df1fa1 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java @@ -39,6 +39,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -67,63 +71,69 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "\n)google/firestore/admin/v1/operation.pr" + "oto\022\031google.firestore.admin.v1\032%google/f" + "irestore/admin/v1/index.proto\032\037google/pr" - + "otobuf/timestamp.proto\032\034google/api/annot" - + "ations.proto\"\275\002\n\026IndexOperationMetadata\022" - + ".\n\nstart_time\030\001 \001(\0132\032.google.protobuf.Ti" - + "mestamp\022,\n\010end_time\030\002 \001(\0132\032.google.proto" - + "buf.Timestamp\022\r\n\005index\030\003 \001(\t\0228\n\005state\030\004 " - + "\001(\0162).google.firestore.admin.v1.Operatio" - + "nState\022?\n\022progress_documents\030\005 \001(\0132#.goo" - + "gle.firestore.admin.v1.Progress\022;\n\016progr" - + "ess_bytes\030\006 \001(\0132#.google.firestore.admin" - + ".v1.Progress\"\210\005\n\026FieldOperationMetadata\022" - + ".\n\nstart_time\030\001 \001(\0132\032.google.protobuf.Ti" - + "mestamp\022,\n\010end_time\030\002 \001(\0132\032.google.proto" - + "buf.Timestamp\022\r\n\005field\030\003 \001(\t\022_\n\023index_co" - + "nfig_deltas\030\004 \003(\0132B.google.firestore.adm" - + "in.v1.FieldOperationMetadata.IndexConfig" - + "Delta\0228\n\005state\030\005 \001(\0162).google.firestore." + + "otobuf/timestamp.proto\"\275\002\n\026IndexOperatio" + + "nMetadata\022.\n\nstart_time\030\001 \001(\0132\032.google.p" + + "rotobuf.Timestamp\022,\n\010end_time\030\002 \001(\0132\032.go" + + "ogle.protobuf.Timestamp\022\r\n\005index\030\003 \001(\t\0228" + + "\n\005state\030\004 \001(\0162).google.firestore.admin.v" + + "1.OperationState\022?\n\022progress_documents\030\005" + + " \001(\0132#.google.firestore.admin.v1.Progres" + + "s\022;\n\016progress_bytes\030\006 \001(\0132#.google.fires" + + "tore.admin.v1.Progress\"\231\007\n\026FieldOperatio" + + "nMetadata\022.\n\nstart_time\030\001 \001(\0132\032.google.p" + + "rotobuf.Timestamp\022,\n\010end_time\030\002 \001(\0132\032.go" + + "ogle.protobuf.Timestamp\022\r\n\005field\030\003 \001(\t\022_" + + "\n\023index_config_deltas\030\004 \003(\0132B.google.fir" + + "estore.admin.v1.FieldOperationMetadata.I" + + "ndexConfigDelta\0228\n\005state\030\005 \001(\0162).google." + + "firestore.admin.v1.OperationState\022?\n\022pro" + + "gress_documents\030\006 \001(\0132#.google.firestore" + + ".admin.v1.Progress\022;\n\016progress_bytes\030\007 \001" + + "(\0132#.google.firestore.admin.v1.Progress\022" + + "Z\n\020ttl_config_delta\030\010 \001(\0132@.google.fires" + + "tore.admin.v1.FieldOperationMetadata.Ttl" + + "ConfigDelta\032\347\001\n\020IndexConfigDelta\022b\n\013chan" + + "ge_type\030\001 \001(\0162M.google.firestore.admin.v" + + "1.FieldOperationMetadata.IndexConfigDelt" + + "a.ChangeType\022/\n\005index\030\002 \001(\0132 .google.fir" + + "estore.admin.v1.Index\">\n\nChangeType\022\033\n\027C" + + "HANGE_TYPE_UNSPECIFIED\020\000\022\007\n\003ADD\020\001\022\n\n\006REM" + + "OVE\020\002\032\262\001\n\016TtlConfigDelta\022`\n\013change_type\030" + + "\001 \001(\0162K.google.firestore.admin.v1.FieldO" + + "perationMetadata.TtlConfigDelta.ChangeTy" + + "pe\">\n\nChangeType\022\033\n\027CHANGE_TYPE_UNSPECIF" + + "IED\020\000\022\007\n\003ADD\020\001\022\n\n\006REMOVE\020\002\"\354\002\n\027ExportDoc" + + "umentsMetadata\022.\n\nstart_time\030\001 \001(\0132\032.goo" + + "gle.protobuf.Timestamp\022,\n\010end_time\030\002 \001(\013" + + "2\032.google.protobuf.Timestamp\022B\n\017operatio" + + "n_state\030\003 \001(\0162).google.firestore.admin.v" + + "1.OperationState\022?\n\022progress_documents\030\004" + + " \001(\0132#.google.firestore.admin.v1.Progres" + + "s\022;\n\016progress_bytes\030\005 \001(\0132#.google.fires" + + "tore.admin.v1.Progress\022\026\n\016collection_ids" + + "\030\006 \003(\t\022\031\n\021output_uri_prefix\030\007 \001(\t\"\353\002\n\027Im" + + "portDocumentsMetadata\022.\n\nstart_time\030\001 \001(" + + "\0132\032.google.protobuf.Timestamp\022,\n\010end_tim" + + "e\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n\017o" + + "peration_state\030\003 \001(\0162).google.firestore." + "admin.v1.OperationState\022?\n\022progress_docu" - + "ments\030\006 \001(\0132#.google.firestore.admin.v1." - + "Progress\022;\n\016progress_bytes\030\007 \001(\0132#.googl" - + "e.firestore.admin.v1.Progress\032\347\001\n\020IndexC" - + "onfigDelta\022b\n\013change_type\030\001 \001(\0162M.google" - + ".firestore.admin.v1.FieldOperationMetada" - + "ta.IndexConfigDelta.ChangeType\022/\n\005index\030" - + "\002 \001(\0132 .google.firestore.admin.v1.Index\"" - + ">\n\nChangeType\022\033\n\027CHANGE_TYPE_UNSPECIFIED" - + "\020\000\022\007\n\003ADD\020\001\022\n\n\006REMOVE\020\002\"\354\002\n\027ExportDocume" - + "ntsMetadata\022.\n\nstart_time\030\001 \001(\0132\032.google" - + ".protobuf.Timestamp\022,\n\010end_time\030\002 \001(\0132\032." - + "google.protobuf.Timestamp\022B\n\017operation_s" - + "tate\030\003 \001(\0162).google.firestore.admin.v1.O" - + "perationState\022?\n\022progress_documents\030\004 \001(" - + "\0132#.google.firestore.admin.v1.Progress\022;" - + "\n\016progress_bytes\030\005 \001(\0132#.google.firestor" - + "e.admin.v1.Progress\022\026\n\016collection_ids\030\006 " - + "\003(\t\022\031\n\021output_uri_prefix\030\007 \001(\t\"\353\002\n\027Impor" - + "tDocumentsMetadata\022.\n\nstart_time\030\001 \001(\0132\032" - + ".google.protobuf.Timestamp\022,\n\010end_time\030\002" - + " \001(\0132\032.google.protobuf.Timestamp\022B\n\017oper" - + "ation_state\030\003 \001(\0162).google.firestore.adm" - + "in.v1.OperationState\022?\n\022progress_documen" - + "ts\030\004 \001(\0132#.google.firestore.admin.v1.Pro" - + "gress\022;\n\016progress_bytes\030\005 \001(\0132#.google.f" - + "irestore.admin.v1.Progress\022\026\n\016collection" - + "_ids\030\006 \003(\t\022\030\n\020input_uri_prefix\030\007 \001(\t\"4\n\027" - + "ExportDocumentsResponse\022\031\n\021output_uri_pr" - + "efix\030\001 \001(\t\":\n\010Progress\022\026\n\016estimated_work" - + "\030\001 \001(\003\022\026\n\016completed_work\030\002 \001(\003*\236\001\n\016Opera" - + "tionState\022\037\n\033OPERATION_STATE_UNSPECIFIED" - + "\020\000\022\020\n\014INITIALIZING\020\001\022\016\n\nPROCESSING\020\002\022\016\n\n" - + "CANCELLING\020\003\022\016\n\nFINALIZING\020\004\022\016\n\nSUCCESSF" - + "UL\020\005\022\n\n\006FAILED\020\006\022\r\n\tCANCELLED\020\007B\342\001\n\035com." - + "google.firestore.admin.v1B\016OperationProt" - + "oP\001Z>google.golang.org/genproto/googleap" - + "is/firestore/admin/v1;admin\242\002\004GCFS\252\002\037Goo" - + "gle.Cloud.Firestore.Admin.V1\312\002\037Google\\Cl" - + "oud\\Firestore\\Admin\\V1\352\002#Google::Cloud::" - + "Firestore::Admin::V1b\006proto3" + + "ments\030\004 \001(\0132#.google.firestore.admin.v1." + + "Progress\022;\n\016progress_bytes\030\005 \001(\0132#.googl" + + "e.firestore.admin.v1.Progress\022\026\n\016collect" + + "ion_ids\030\006 \003(\t\022\030\n\020input_uri_prefix\030\007 \001(\t\"" + + "4\n\027ExportDocumentsResponse\022\031\n\021output_uri" + + "_prefix\030\001 \001(\t\":\n\010Progress\022\026\n\016estimated_w" + + "ork\030\001 \001(\003\022\026\n\016completed_work\030\002 \001(\003*\236\001\n\016Op" + + "erationState\022\037\n\033OPERATION_STATE_UNSPECIF" + + "IED\020\000\022\020\n\014INITIALIZING\020\001\022\016\n\nPROCESSING\020\002\022" + + "\016\n\nCANCELLING\020\003\022\016\n\nFINALIZING\020\004\022\016\n\nSUCCE" + + "SSFUL\020\005\022\n\n\006FAILED\020\006\022\r\n\tCANCELLED\020\007B\342\001\n\035c" + + "om.google.firestore.admin.v1B\016OperationP" + + "rotoP\001Z>google.golang.org/genproto/googl" + + "eapis/firestore/admin/v1;admin\242\002\004GCFS\252\002\037" + + "Google.Cloud.Firestore.Admin.V1\312\002\037Google" + + "\\Cloud\\Firestore\\Admin\\V1\352\002#Google::Clou" + + "d::Firestore::Admin::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -131,7 +141,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.Descriptors.FileDescriptor[] { com.google.firestore.admin.v1.IndexProto.getDescriptor(), com.google.protobuf.TimestampProto.getDescriptor(), - com.google.api.AnnotationsProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor = getDescriptor().getMessageTypes().get(0); @@ -154,6 +163,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "State", "ProgressDocuments", "ProgressBytes", + "TtlConfigDelta", }); internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor = internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor @@ -165,6 +175,16 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "ChangeType", "Index", }); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor = + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor + .getNestedTypes() + .get(1); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor, + new java.lang.String[] { + "ChangeType", + }); internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_fieldAccessorTable = @@ -211,7 +231,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { }); com.google.firestore.admin.v1.IndexProto.getDescriptor(); com.google.protobuf.TimestampProto.getDescriptor(); - com.google.api.AnnotationsProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto index 5b2cd7b6c..3f242c3e1 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -18,9 +18,6 @@ package google.firestore.admin.v1; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; @@ -44,6 +41,8 @@ message Database { // The type of the database. // See https://cloud.google.com/datastore/docs/firestore-or-datastore for // information about how to choose. + // + // Mode changes are only allowed if the database is empty. enum DatabaseType { // The default value. This value is used if the database type is omitted. DATABASE_TYPE_UNSPECIFIED = 0; @@ -60,21 +59,41 @@ message Database { // Not used. CONCURRENCY_MODE_UNSPECIFIED = 0; - // Use optimistic concurrency control by default. This setting is available - // for Cloud Firestore customers. + // Use optimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. OPTIMISTIC = 1; - // Use pessimistic concurrency control by default. This setting is available - // for Cloud Firestore customers. + // Use pessimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. + // // This is the default setting for Cloud Firestore. PESSIMISTIC = 2; - // Use optimistic concurrency control with entity groups by default. This is - // the only available setting for Cloud Datastore customers. - // This is the default setting for Cloud Datastore. + // Use optimistic concurrency control with entity groups by default. + // + // This is the only available mode for Cloud Datastore. + // + // This mode is also available for Cloud Firestore with Datastore Mode but + // is not recommended. OPTIMISTIC_WITH_ENTITY_GROUPS = 3; } + // The type of App Engine integration mode. + enum AppEngineIntegrationMode { + // Not used. + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + + // If an App Engine application exists in the same region as this database, + // App Engine configuration will impact this database. This includes + // disabling of the application & database, as well as disabling writes to + // the database. + ENABLED = 1; + + // Appengine has no affect on the ability of this database to serve + // requests. + DISABLED = 2; + } + // The resource name of the Database. // Format: `projects/{project}/databases/{database}` string name = 1; @@ -91,6 +110,18 @@ message Database { // The concurrency control mode to use for this database. ConcurrencyMode concurrency_mode = 15; + // The App Engine integration mode to use for this database. + AppEngineIntegrationMode app_engine_integration_mode = 19; + + // Output only. The key_prefix for this database. This key_prefix is used, in combination + // with the project id ("~") to construct the + // application id that is returned from the Cloud Datastore APIs in Google App + // Engine first generation runtimes. + // + // This value may be empty in which case the appid to use for URL-encoded keys + // is the project_id (eg: foo instead of v~foo). + string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + // This checksum is computed by the server based on the value of other // fields, and may be sent on update and delete requests to ensure the // client has an up-to-date value before proceeding. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto index 3e4224395..0bbb11d8a 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -19,7 +19,6 @@ package google.firestore.admin.v1; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/firestore/admin/v1/index.proto"; -import "google/api/annotations.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; @@ -64,6 +63,38 @@ message Field { bool reverting = 4; } + // The TTL (time-to-live) configuration for documents that have this `Field` + // set. + // Storing a timestamp value into a TTL-enabled field will be treated as + // the document's absolute expiration time. Using any other data type or + // leaving the field absent will disable the TTL for the individual document. + message TtlConfig { + // The state of applying the TTL configuration to all documents. + enum State { + // The state is unspecified or unknown. + STATE_UNSPECIFIED = 0; + + // The TTL is being applied. There is an active long-running operation to + // track the change. Newly written documents will have TTLs applied as + // requested. Requested TTLs on existing documents are still being + // processed. When TTLs on all existing documents have been processed, the + // state will move to 'ACTIVE'. + CREATING = 1; + + // The TTL is active for all documents. + ACTIVE = 2; + + // The TTL configuration could not be enabled for all existing documents. + // Newly written documents will continue to have their TTL applied. + // The LRO returned when last attempting to enable TTL for this `Field` + // has failed, and may have more details. + NEEDS_REPAIR = 3; + } + + // Output only. The state of the TTL configuration. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + // Required. A field name of the form // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` // @@ -97,4 +128,9 @@ message Field { // explicitly remove all indexes for this field, specify an index config // with an empty list of indexes. IndexConfig index_config = 2; + + // The TTL configuration for this `Field`. + // Setting or unsetting this will enable or disable the TTL for + // documents that have this `Field`. + TtlConfig ttl_config = 3; } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto index 772ea214b..c493673ae 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -23,11 +23,9 @@ import "google/api/resource.proto"; import "google/firestore/admin/v1/database.proto"; import "google/firestore/admin/v1/field.proto"; import "google/firestore/admin/v1/index.proto"; -import "google/firestore/admin/v1/operation.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto index 7e330a99c..066d4109f 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -17,7 +17,6 @@ syntax = "proto3"; package google.firestore.admin.v1; import "google/api/resource.proto"; -import "google/api/annotations.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; @@ -36,6 +35,23 @@ message Index { pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" }; + // Query Scope defines the scope at which a query is run. This is specified on + // a StructuredQuery's `from` field. + enum QueryScope { + // The query scope is unspecified. Not a valid option. + QUERY_SCOPE_UNSPECIFIED = 0; + + // Indexes with a collection query scope specified allow queries + // against a collection that is the child of a specific document, specified + // at query time, and that has the collection id specified by the index. + COLLECTION = 1; + + // Indexes with a collection group query scope specified allow queries + // against all collections that has the collection id specified by the + // index. + COLLECTION_GROUP = 2; + } + // A field in an index. // The field_path describes which field is indexed, the value_mode describes // how the field value is indexed. @@ -77,23 +93,6 @@ message Index { } } - // Query Scope defines the scope at which a query is run. This is specified on - // a StructuredQuery's `from` field. - enum QueryScope { - // The query scope is unspecified. Not a valid option. - QUERY_SCOPE_UNSPECIFIED = 0; - - // Indexes with a collection query scope specified allow queries - // against a collection that is the child of a specific document, specified - // at query time, and that has the collection id specified by the index. - COLLECTION = 1; - - // Indexes with a collection group query scope specified allow queries - // against all collections that has the collection id specified by the - // index. - COLLECTION_GROUP = 2; - } - // The state of an index. During index creation, an index will be in the // `CREATING` state. If the index is created successfully, it will transition // to the `READY` state. If the index creation encounters a problem, the index diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto index ce34de36b..8f7519c4d 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -16,9 +16,6 @@ syntax = "proto3"; package google.firestore.admin.v1; -import "google/type/latlng.proto"; -import "google/api/annotations.proto"; - option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; option java_multiple_files = true; diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto index 1b918fdb1..654a6ad6c 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -18,7 +18,6 @@ package google.firestore.admin.v1; import "google/firestore/admin/v1/index.proto"; import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; option go_package = "google.golang.org/genproto/googleapis/firestore/admin/v1;admin"; @@ -77,6 +76,24 @@ message FieldOperationMetadata { Index index = 2; } + // Information about an TTL configuration change. + message TtlConfigDelta { + // Specifies how the TTL config is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The TTL config is being added. + ADD = 1; + + // The TTL config is being removed. + REMOVE = 2; + } + + // Specifies how the TTL configuration is changing. + ChangeType change_type = 1; + } + // The time this operation started. google.protobuf.Timestamp start_time = 1; @@ -100,6 +117,9 @@ message FieldOperationMetadata { // The progress, in bytes, of this operation. Progress progress_bytes = 7; + + // Describes the deltas of TTL configuration. + TtlConfigDelta ttl_config_delta = 8; } // Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java index 0b9c35b51..d49acb2cb 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java @@ -236,150 +236,153 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "(\0132\035.google.firestore.v1.Document\022-\n\trea" + "d_time\030\003 \001(\0132\032.google.protobuf.Timestamp" + "\022\027\n\017skipped_results\030\004 \001(\005\022\016\n\004done\030\006 \001(\010H" - + "\000B\027\n\025continuation_selector\"\274\001\n\025Partition" + + "\000B\027\n\025continuation_selector\"\205\002\n\025Partition" + "QueryRequest\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022@\n\020str" + "uctured_query\030\002 \001(\0132$.google.firestore.v" + "1.StructuredQueryH\000\022\027\n\017partition_count\030\003" + " \001(\003\022\022\n\npage_token\030\004 \001(\t\022\021\n\tpage_size\030\005 " - + "\001(\005B\014\n\nquery_type\"b\n\026PartitionQueryRespo" - + "nse\022/\n\npartitions\030\001 \003(\0132\033.google.firesto" - + "re.v1.Cursor\022\027\n\017next_page_token\030\002 \001(\t\"\350\001" - + "\n\014WriteRequest\022\025\n\010database\030\001 \001(\tB\003\340A\002\022\021\n" - + "\tstream_id\030\002 \001(\t\022*\n\006writes\030\003 \003(\0132\032.googl" - + "e.firestore.v1.Write\022\024\n\014stream_token\030\004 \001" - + "(\014\022=\n\006labels\030\005 \003(\0132-.google.firestore.v1" - + ".WriteRequest.LabelsEntry\032-\n\013LabelsEntry" - + "\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\242\001\n\rWri" - + "teResponse\022\021\n\tstream_id\030\001 \001(\t\022\024\n\014stream_" - + "token\030\002 \001(\014\0227\n\rwrite_results\030\003 \003(\0132 .goo" - + "gle.firestore.v1.WriteResult\022/\n\013commit_t" - + "ime\030\004 \001(\0132\032.google.protobuf.Timestamp\"\362\001" - + "\n\rListenRequest\022\025\n\010database\030\001 \001(\tB\003\340A\002\0221" - + "\n\nadd_target\030\002 \001(\0132\033.google.firestore.v1" - + ".TargetH\000\022\027\n\rremove_target\030\003 \001(\005H\000\022>\n\006la" - + "bels\030\004 \003(\0132..google.firestore.v1.ListenR" + + "\001(\005\022/\n\tread_time\030\006 \001(\0132\032.google.protobuf" + + ".TimestampH\001B\014\n\nquery_typeB\026\n\024consistenc" + + "y_selector\"b\n\026PartitionQueryResponse\022/\n\n" + + "partitions\030\001 \003(\0132\033.google.firestore.v1.C" + + "ursor\022\027\n\017next_page_token\030\002 \001(\t\"\350\001\n\014Write" + + "Request\022\025\n\010database\030\001 \001(\tB\003\340A\002\022\021\n\tstream" + + "_id\030\002 \001(\t\022*\n\006writes\030\003 \003(\0132\032.google.fires" + + "tore.v1.Write\022\024\n\014stream_token\030\004 \001(\014\022=\n\006l" + + "abels\030\005 \003(\0132-.google.firestore.v1.WriteR" + "equest.LabelsEntry\032-\n\013LabelsEntry\022\013\n\003key" - + "\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001B\017\n\rtarget_chan" - + "ge\"\325\002\n\016ListenResponse\022:\n\rtarget_change\030\002" - + " \001(\0132!.google.firestore.v1.TargetChangeH" - + "\000\022>\n\017document_change\030\003 \001(\0132#.google.fire" - + "store.v1.DocumentChangeH\000\022>\n\017document_de" - + "lete\030\004 \001(\0132#.google.firestore.v1.Documen" - + "tDeleteH\000\022>\n\017document_remove\030\006 \001(\0132#.goo" - + "gle.firestore.v1.DocumentRemoveH\000\0226\n\006fil" - + "ter\030\005 \001(\0132$.google.firestore.v1.Existenc" - + "eFilterH\000B\017\n\rresponse_type\"\241\003\n\006Target\0228\n" - + "\005query\030\002 \001(\0132\'.google.firestore.v1.Targe" - + "t.QueryTargetH\000\022@\n\tdocuments\030\003 \001(\0132+.goo" - + "gle.firestore.v1.Target.DocumentsTargetH" - + "\000\022\026\n\014resume_token\030\004 \001(\014H\001\022/\n\tread_time\030\013" - + " \001(\0132\032.google.protobuf.TimestampH\001\022\021\n\tta" - + "rget_id\030\005 \001(\005\022\014\n\004once\030\006 \001(\010\032$\n\017Documents" - + "Target\022\021\n\tdocuments\030\002 \003(\t\032m\n\013QueryTarget" - + "\022\016\n\006parent\030\001 \001(\t\022@\n\020structured_query\030\002 \001" - + "(\0132$.google.firestore.v1.StructuredQuery" - + "H\000B\014\n\nquery_typeB\r\n\013target_typeB\r\n\013resum" - + "e_type\"\252\002\n\014TargetChange\022N\n\022target_change" - + "_type\030\001 \001(\01622.google.firestore.v1.Target" - + "Change.TargetChangeType\022\022\n\ntarget_ids\030\002 " - + "\003(\005\022!\n\005cause\030\003 \001(\0132\022.google.rpc.Status\022\024" - + "\n\014resume_token\030\004 \001(\014\022-\n\tread_time\030\006 \001(\0132" - + "\032.google.protobuf.Timestamp\"N\n\020TargetCha" - + "ngeType\022\r\n\tNO_CHANGE\020\000\022\007\n\003ADD\020\001\022\n\n\006REMOV" - + "E\020\002\022\013\n\007CURRENT\020\003\022\t\n\005RESET\020\004\"V\n\030ListColle" - + "ctionIdsRequest\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022\021\n\t" - + "page_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"L\n\031L" - + "istCollectionIdsResponse\022\026\n\016collection_i" - + "ds\030\001 \003(\t\022\027\n\017next_page_token\030\002 \001(\t\"\311\001\n\021Ba" - + "tchWriteRequest\022\025\n\010database\030\001 \001(\tB\003\340A\002\022*" - + "\n\006writes\030\002 \003(\0132\032.google.firestore.v1.Wri" - + "te\022B\n\006labels\030\003 \003(\01322.google.firestore.v1" - + ".BatchWriteRequest.LabelsEntry\032-\n\013Labels" - + "Entry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"q\n" - + "\022BatchWriteResponse\0227\n\rwrite_results\030\001 \003" - + "(\0132 .google.firestore.v1.WriteResult\022\"\n\006" - + "status\030\002 \003(\0132\022.google.rpc.Status2\300\027\n\tFir" - + "estore\022\217\001\n\013GetDocument\022\'.google.firestor" - + "e.v1.GetDocumentRequest\032\035.google.firesto" - + "re.v1.Document\"8\202\323\344\223\0022\0220/v1/{name=projec" - + "ts/*/databases/*/documents/*/**}\022\365\001\n\rLis" - + "tDocuments\022).google.firestore.v1.ListDoc" - + "umentsRequest\032*.google.firestore.v1.List" - + "DocumentsResponse\"\214\001\202\323\344\223\002\205\001\022B/v1/{parent" - + "=projects/*/databases/*/documents/*/**}/" - + "{collection_id}Z?\022=/v1/{parent=projects/" - + "*/databases/*/documents}/{collection_id}" - + "\022\277\001\n\016UpdateDocument\022*.google.firestore.v" - + "1.UpdateDocumentRequest\032\035.google.firesto" - + "re.v1.Document\"b\202\323\344\223\002E29/v1/{document.na" - + "me=projects/*/databases/*/documents/*/**" - + "}:\010document\332A\024document,update_mask\022\225\001\n\016D" - + "eleteDocument\022*.google.firestore.v1.Dele" - + "teDocumentRequest\032\026.google.protobuf.Empt" - + "y\"?\202\323\344\223\0022*0/v1/{name=projects/*/database" - + "s/*/documents/*/**}\332A\004name\022\271\001\n\021BatchGetD" - + "ocuments\022-.google.firestore.v1.BatchGetD" - + "ocumentsRequest\032..google.firestore.v1.Ba" - + "tchGetDocumentsResponse\"C\202\323\344\223\002=\"8/v1/{da" - + "tabase=projects/*/databases/*}/documents" - + ":batchGet:\001*0\001\022\307\001\n\020BeginTransaction\022,.go" - + "ogle.firestore.v1.BeginTransactionReques" - + "t\032-.google.firestore.v1.BeginTransaction" - + "Response\"V\202\323\344\223\002E\"@/v1/{database=projects" - + "/*/databases/*}/documents:beginTransacti" - + "on:\001*\332A\010database\022\246\001\n\006Commit\022\".google.fir" - + "estore.v1.CommitRequest\032#.google.firesto" - + "re.v1.CommitResponse\"S\202\323\344\223\002;\"6/v1/{datab" - + "ase=projects/*/databases/*}/documents:co" - + "mmit:\001*\332A\017database,writes\022\244\001\n\010Rollback\022$" - + ".google.firestore.v1.RollbackRequest\032\026.g" - + "oogle.protobuf.Empty\"Z\202\323\344\223\002=\"8/v1/{datab" - + "ase=projects/*/databases/*}/documents:ro" - + "llback:\001*\332A\024database,transaction\022\337\001\n\010Run" - + "Query\022$.google.firestore.v1.RunQueryRequ" - + "est\032%.google.firestore.v1.RunQueryRespon" - + "se\"\203\001\202\323\344\223\002}\"6/v1/{parent=projects/*/data" - + "bases/*/documents}:runQuery:\001*Z@\";/v1/{p" - + "arent=projects/*/databases/*/documents/*" - + "/**}:runQuery:\001*0\001\022\374\001\n\016PartitionQuery\022*." - + "google.firestore.v1.PartitionQueryReques" - + "t\032+.google.firestore.v1.PartitionQueryRe" - + "sponse\"\220\001\202\323\344\223\002\211\001\"\n\006labels\030\004 " + + "\003(\0132..google.firestore.v1.ListenRequest." + + "LabelsEntry\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022" + + "\r\n\005value\030\002 \001(\t:\0028\001B\017\n\rtarget_change\"\325\002\n\016" + + "ListenResponse\022:\n\rtarget_change\030\002 \001(\0132!." + + "google.firestore.v1.TargetChangeH\000\022>\n\017do" + + "cument_change\030\003 \001(\0132#.google.firestore.v" + + "1.DocumentChangeH\000\022>\n\017document_delete\030\004 " + + "\001(\0132#.google.firestore.v1.DocumentDelete" + + "H\000\022>\n\017document_remove\030\006 \001(\0132#.google.fir" + + "estore.v1.DocumentRemoveH\000\0226\n\006filter\030\005 \001" + + "(\0132$.google.firestore.v1.ExistenceFilter" + + "H\000B\017\n\rresponse_type\"\241\003\n\006Target\0228\n\005query\030" + + "\002 \001(\0132\'.google.firestore.v1.Target.Query" + + "TargetH\000\022@\n\tdocuments\030\003 \001(\0132+.google.fir" + + "estore.v1.Target.DocumentsTargetH\000\022\026\n\014re" + + "sume_token\030\004 \001(\014H\001\022/\n\tread_time\030\013 \001(\0132\032." + + "google.protobuf.TimestampH\001\022\021\n\ttarget_id" + + "\030\005 \001(\005\022\014\n\004once\030\006 \001(\010\032$\n\017DocumentsTarget\022" + + "\021\n\tdocuments\030\002 \003(\t\032m\n\013QueryTarget\022\016\n\006par" + + "ent\030\001 \001(\t\022@\n\020structured_query\030\002 \001(\0132$.go" + + "ogle.firestore.v1.StructuredQueryH\000B\014\n\nq" + + "uery_typeB\r\n\013target_typeB\r\n\013resume_type\"" + + "\252\002\n\014TargetChange\022N\n\022target_change_type\030\001" + + " \001(\01622.google.firestore.v1.TargetChange." + + "TargetChangeType\022\022\n\ntarget_ids\030\002 \003(\005\022!\n\005" + + "cause\030\003 \001(\0132\022.google.rpc.Status\022\024\n\014resum" + + "e_token\030\004 \001(\014\022-\n\tread_time\030\006 \001(\0132\032.googl" + + "e.protobuf.Timestamp\"N\n\020TargetChangeType" + + "\022\r\n\tNO_CHANGE\020\000\022\007\n\003ADD\020\001\022\n\n\006REMOVE\020\002\022\013\n\007" + + "CURRENT\020\003\022\t\n\005RESET\020\004\"\237\001\n\030ListCollectionI" + + "dsRequest\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022\021\n\tpage_s" + + "ize\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\022/\n\tread_ti" + + "me\030\004 \001(\0132\032.google.protobuf.TimestampH\000B\026" + + "\n\024consistency_selector\"L\n\031ListCollection" + + "IdsResponse\022\026\n\016collection_ids\030\001 \003(\t\022\027\n\017n" + + "ext_page_token\030\002 \001(\t\"\311\001\n\021BatchWriteReque" + + "st\022\025\n\010database\030\001 \001(\tB\003\340A\002\022*\n\006writes\030\002 \003(" + + "\0132\032.google.firestore.v1.Write\022B\n\006labels\030" + + "\003 \003(\01322.google.firestore.v1.BatchWriteRe" + + "quest.LabelsEntry\032-\n\013LabelsEntry\022\013\n\003key\030" + + "\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"q\n\022BatchWriteRe" + + "sponse\0227\n\rwrite_results\030\001 \003(\0132 .google.f" + + "irestore.v1.WriteResult\022\"\n\006status\030\002 \003(\0132" + + "\022.google.rpc.Status2\300\027\n\tFirestore\022\217\001\n\013Ge" + + "tDocument\022\'.google.firestore.v1.GetDocum" + + "entRequest\032\035.google.firestore.v1.Documen" + + "t\"8\202\323\344\223\0022\0220/v1/{name=projects/*/database" + + "s/*/documents/*/**}\022\365\001\n\rListDocuments\022)." + + "google.firestore.v1.ListDocumentsRequest" + + "\032*.google.firestore.v1.ListDocumentsResp" + + "onse\"\214\001\202\323\344\223\002\205\001\022B/v1/{parent=projects/*/d" + + "atabases/*/documents/*/**}/{collection_i" + + "d}Z?\022=/v1/{parent=projects/*/databases/*" + + "/documents}/{collection_id}\022\277\001\n\016UpdateDo" + + "cument\022*.google.firestore.v1.UpdateDocum" + + "entRequest\032\035.google.firestore.v1.Documen" + + "t\"b\202\323\344\223\002E29/v1/{document.name=projects/*" + + "/databases/*/documents/*/**}:\010document\332A" + + "\024document,update_mask\022\225\001\n\016DeleteDocument" + + "\022*.google.firestore.v1.DeleteDocumentReq" + + "uest\032\026.google.protobuf.Empty\"?\202\323\344\223\0022*0/v" + + "1/{name=projects/*/databases/*/documents" + + "/*/**}\332A\004name\022\271\001\n\021BatchGetDocuments\022-.go" + + "ogle.firestore.v1.BatchGetDocumentsReque" + + "st\032..google.firestore.v1.BatchGetDocumen" + + "tsResponse\"C\202\323\344\223\002=\"8/v1/{database=projec" + + "ts/*/databases/*}/documents:batchGet:\001*0" + + "\001\022\307\001\n\020BeginTransaction\022,.google.firestor" + + "e.v1.BeginTransactionRequest\032-.google.fi" + + "restore.v1.BeginTransactionResponse\"V\202\323\344" + + "\223\002E\"@/v1/{database=projects/*/databases/" + + "*}/documents:beginTransaction:\001*\332A\010datab" + + "ase\022\246\001\n\006Commit\022\".google.firestore.v1.Com" + + "mitRequest\032#.google.firestore.v1.CommitR" + + "esponse\"S\202\323\344\223\002;\"6/v1/{database=projects/" + + "*/databases/*}/documents:commit:\001*\332A\017dat" + + "abase,writes\022\244\001\n\010Rollback\022$.google.fires" + + "tore.v1.RollbackRequest\032\026.google.protobu" + + "f.Empty\"Z\202\323\344\223\002=\"8/v1/{database=projects/" + + "*/databases/*}/documents:rollback:\001*\332A\024d" + + "atabase,transaction\022\337\001\n\010RunQuery\022$.googl" + + "e.firestore.v1.RunQueryRequest\032%.google." + + "firestore.v1.RunQueryResponse\"\203\001\202\323\344\223\002}\"6" + + "/v1/{parent=projects/*/databases/*/docum" + + "ents}:runQuery:\001*Z@\";/v1/{parent=project" + + "s/*/databases/*/documents/*/**}:runQuery" + + ":\001*0\001\022\374\001\n\016PartitionQuery\022*.google.firest" + + "ore.v1.PartitionQueryRequest\032+.google.fi" + + "restore.v1.PartitionQueryResponse\"\220\001\202\323\344\223" + + "\002\211\001\" + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * + * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 4; + } + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -273,6 +386,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_); } + if (consistencySelectorCase_ == 4) { + output.writeMessage(4, (com.google.protobuf.Timestamp) consistencySelector_); + } unknownFields.writeTo(output); } @@ -291,6 +407,11 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_); } + if (consistencySelectorCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.protobuf.Timestamp) consistencySelector_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -310,6 +431,14 @@ public boolean equals(final java.lang.Object obj) { if (!getParent().equals(other.getParent())) return false; if (getPageSize() != other.getPageSize()) return false; if (!getPageToken().equals(other.getPageToken())) return false; + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 4: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -327,6 +456,14 @@ public int hashCode() { hash = (53 * hash) + getPageSize(); hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getPageToken().hashCode(); + switch (consistencySelectorCase_) { + case 4: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -478,6 +615,8 @@ public Builder clear() { pageToken_ = ""; + consistencySelectorCase_ = 0; + consistencySelector_ = null; return this; } @@ -508,6 +647,14 @@ public com.google.firestore.v1.ListCollectionIdsRequest buildPartial() { result.parent_ = parent_; result.pageSize_ = pageSize_; result.pageToken_ = pageToken_; + if (consistencySelectorCase_ == 4) { + if (readTimeBuilder_ == null) { + result.consistencySelector_ = consistencySelector_; + } else { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + result.consistencySelectorCase_ = consistencySelectorCase_; onBuilt(); return result; } @@ -569,6 +716,17 @@ public Builder mergeFrom(com.google.firestore.v1.ListCollectionIdsRequest other) pageToken_ = other.pageToken_; onChanged(); } + switch (other.getConsistencySelectorCase()) { + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -598,6 +756,20 @@ public Builder mergeFrom( return this; } + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + private java.lang.Object parent_ = ""; /** * @@ -882,6 +1054,224 @@ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { return this; } + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 4; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 4) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 4; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 4; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 4) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 4; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return getReadTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 4) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 4)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 4; + onChanged(); + ; + return readTimeBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java index c1c616cd9..7a09c0995 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java @@ -93,4 +93,45 @@ public interface ListCollectionIdsRequestOrBuilder * @return The bytes for pageToken. */ com.google.protobuf.ByteString getPageTokenBytes(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + public com.google.firestore.v1.ListCollectionIdsRequest.ConsistencySelectorCase + getConsistencySelectorCase(); } diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java index 705a543ea..b175ee7f1 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java @@ -111,6 +111,21 @@ private PartitionQueryRequest( pageSize_ = input.readInt32(); break; } + case 50: + { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (consistencySelectorCase_ == 6) { + subBuilder = ((com.google.protobuf.Timestamp) consistencySelector_).toBuilder(); + } + consistencySelector_ = + input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((com.google.protobuf.Timestamp) consistencySelector_); + consistencySelector_ = subBuilder.buildPartial(); + } + consistencySelectorCase_ = 6; + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -191,6 +206,50 @@ public QueryTypeCase getQueryTypeCase() { return QueryTypeCase.forNumber(queryTypeCase_); } + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_TIME(6), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 6: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + public static final int PARENT_FIELD_NUMBER = 1; private volatile java.lang.Object parent_; /** @@ -420,6 +479,60 @@ public int getPageSize() { return pageSize_; } + public static final int READ_TIME_FIELD_NUMBER = 6; + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -449,6 +562,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (pageSize_ != 0) { output.writeInt32(5, pageSize_); } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.protobuf.Timestamp) consistencySelector_); + } unknownFields.writeTo(output); } @@ -475,6 +591,11 @@ public int getSerializedSize() { if (pageSize_ != 0) { size += com.google.protobuf.CodedOutputStream.computeInt32Size(5, pageSize_); } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.protobuf.Timestamp) consistencySelector_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -503,6 +624,14 @@ public boolean equals(final java.lang.Object obj) { case 0: default: } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 6: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -530,6 +659,14 @@ public int hashCode() { case 0: default: } + switch (consistencySelectorCase_) { + case 6: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -685,6 +822,8 @@ public Builder clear() { queryTypeCase_ = 0; queryType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; return this; } @@ -723,7 +862,15 @@ public com.google.firestore.v1.PartitionQueryRequest buildPartial() { result.partitionCount_ = partitionCount_; result.pageToken_ = pageToken_; result.pageSize_ = pageSize_; + if (consistencySelectorCase_ == 6) { + if (readTimeBuilder_ == null) { + result.consistencySelector_ = consistencySelector_; + } else { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } result.queryTypeCase_ = queryTypeCase_; + result.consistencySelectorCase_ = consistencySelectorCase_; onBuilt(); return result; } @@ -798,6 +945,17 @@ public Builder mergeFrom(com.google.firestore.v1.PartitionQueryRequest other) { break; } } + switch (other.getConsistencySelectorCase()) { + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -841,6 +999,20 @@ public Builder clearQueryType() { return this; } + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + private java.lang.Object parent_ = ""; /** * @@ -1487,6 +1659,224 @@ public Builder clearPageSize() { return this; } + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return getReadTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 6) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Reads documents as they were at the given time.
+     * This may not be older than 270 seconds.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + ; + return readTimeBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java index eb772e31b..bbd49e9ae 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java @@ -178,5 +178,46 @@ public interface PartitionQueryRequestOrBuilder */ int getPageSize(); + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + /** + * + * + *
+   * Reads documents as they were at the given time.
+   * This may not be older than 270 seconds.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + public com.google.firestore.v1.PartitionQueryRequest.QueryTypeCase getQueryTypeCase(); + + public com.google.firestore.v1.PartitionQueryRequest.ConsistencySelectorCase + getConsistencySelectorCase(); } diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto index 17c94ecb4..8bac56a3d 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto @@ -584,6 +584,14 @@ message PartitionQueryRequest { // if more results exist. A second call to PartitionQuery will return up to // 2 partitions, to complete the total of 10 specified in `partition_count`. int32 page_size = 5; + + // The consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 6; + } } // The response for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. @@ -868,6 +876,14 @@ message ListCollectionIdsRequest { // A page token. Must be a value from // [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. string page_token = 3; + + // The consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 4; + } } // The response from [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].