diff --git a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java index 857ce007cb94..91900229a3f7 100644 --- a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java +++ b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java @@ -27,7 +27,6 @@ import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.ServerStreamingCallable; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.firestore.v1.stub.FirestoreStub; import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; import com.google.firestore.v1.BatchGetDocumentsRequest; @@ -145,137 +144,6 @@ public class FirestoreClient implements BackgroundResource { private final FirestoreSettings settings; private final FirestoreStub stub; - private static final PathTemplate DATABASE_ROOT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}"); - - private static final PathTemplate DOCUMENT_ROOT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}/documents"); - - private static final PathTemplate DOCUMENT_PATH_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/databases/{database}/documents/{document_path=**}"); - - private static final PathTemplate ANY_PATH_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/databases/{database}/documents/{document}/{any_path=**}"); - - /** Formats a string containing the fully-qualified path to represent a database_root resource. */ - public static final String formatDatabaseRootName(String project, String database) { - return DATABASE_ROOT_PATH_TEMPLATE.instantiate( - "project", project, - "database", database); - } - - /** Formats a string containing the fully-qualified path to represent a document_root resource. */ - public static final String formatDocumentRootName(String project, String database) { - return DOCUMENT_ROOT_PATH_TEMPLATE.instantiate( - "project", project, - "database", database); - } - - /** Formats a string containing the fully-qualified path to represent a document_path resource. */ - public static final String formatDocumentPathName( - String project, String database, String documentPath) { - return DOCUMENT_PATH_PATH_TEMPLATE.instantiate( - "project", project, - "database", database, - "document_path", documentPath); - } - - /** Formats a string containing the fully-qualified path to represent a any_path resource. */ - public static final String formatAnyPathName( - String project, String database, String document, String anyPath) { - return ANY_PATH_PATH_TEMPLATE.instantiate( - "project", project, - "database", database, - "document", document, - "any_path", anyPath); - } - - /** - * Parses the project from the given fully-qualified path which represents a database_root - * resource. - */ - public static final String parseProjectFromDatabaseRootName(String databaseRootName) { - return DATABASE_ROOT_PATH_TEMPLATE.parse(databaseRootName).get("project"); - } - - /** - * Parses the database from the given fully-qualified path which represents a database_root - * resource. - */ - public static final String parseDatabaseFromDatabaseRootName(String databaseRootName) { - return DATABASE_ROOT_PATH_TEMPLATE.parse(databaseRootName).get("database"); - } - - /** - * Parses the project from the given fully-qualified path which represents a document_root - * resource. - */ - public static final String parseProjectFromDocumentRootName(String documentRootName) { - return DOCUMENT_ROOT_PATH_TEMPLATE.parse(documentRootName).get("project"); - } - - /** - * Parses the database from the given fully-qualified path which represents a document_root - * resource. - */ - public static final String parseDatabaseFromDocumentRootName(String documentRootName) { - return DOCUMENT_ROOT_PATH_TEMPLATE.parse(documentRootName).get("database"); - } - - /** - * Parses the project from the given fully-qualified path which represents a document_path - * resource. - */ - public static final String parseProjectFromDocumentPathName(String documentPathName) { - return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("project"); - } - - /** - * Parses the database from the given fully-qualified path which represents a document_path - * resource. - */ - public static final String parseDatabaseFromDocumentPathName(String documentPathName) { - return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("database"); - } - - /** - * Parses the document_path from the given fully-qualified path which represents a document_path - * resource. - */ - public static final String parseDocumentPathFromDocumentPathName(String documentPathName) { - return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("document_path"); - } - - /** - * Parses the project from the given fully-qualified path which represents a any_path resource. - */ - public static final String parseProjectFromAnyPathName(String anyPathName) { - return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("project"); - } - - /** - * Parses the database from the given fully-qualified path which represents a any_path resource. - */ - public static final String parseDatabaseFromAnyPathName(String anyPathName) { - return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("database"); - } - - /** - * Parses the document from the given fully-qualified path which represents a any_path resource. - */ - public static final String parseDocumentFromAnyPathName(String anyPathName) { - return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("document"); - } - - /** - * Parses the any_path from the given fully-qualified path which represents a any_path resource. - */ - public static final String parseAnyPathFromAnyPathName(String anyPathName) { - return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("any_path"); - } - /** Constructs an instance of FirestoreClient with default settings. */ public static final FirestoreClient create() throws IOException { return create(FirestoreSettings.newBuilder().build()); @@ -330,7 +198,7 @@ public FirestoreStub getStub() { * *
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* GetDocumentRequest request = GetDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -353,7 +221,7 @@ public final Document getDocument(GetDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* GetDocumentRequest request = GetDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -375,7 +243,7 @@ public final UnaryCallable getDocumentCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -402,7 +270,7 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -429,7 +297,7 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -462,7 +330,7 @@ public final UnaryCallable listDocu
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* String documentId = "";
* Document document = Document.newBuilder().build();
@@ -491,7 +359,7 @@ public final Document createDocument(CreateDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* String documentId = "";
* Document document = Document.newBuilder().build();
@@ -597,7 +465,7 @@ public final UnaryCallable updateDocumentCallab
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* firestoreClient.deleteDocument(formattedName);
* }
*
@@ -607,7 +475,7 @@ public final UnaryCallable updateDocumentCallab
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDocument(String name) {
- ANY_PATH_PATH_TEMPLATE.validate(name, "deleteDocument");
+
DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build();
deleteDocument(request);
}
@@ -620,7 +488,7 @@ public final void deleteDocument(String name) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -643,7 +511,7 @@ public final void deleteDocument(DeleteDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -668,7 +536,7 @@ public final UnaryCallable deleteDocumentCallable(
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<String> documents = new ArrayList<>();
* BatchGetDocumentsRequest request = BatchGetDocumentsRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -695,7 +563,7 @@ public final UnaryCallable deleteDocumentCallable(
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionResponse response = firestoreClient.beginTransaction(formattedDatabase);
* }
*
@@ -705,7 +573,7 @@ public final UnaryCallable deleteDocumentCallable(
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final BeginTransactionResponse beginTransaction(String database) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "beginTransaction");
+
BeginTransactionRequest request =
BeginTransactionRequest.newBuilder().setDatabase(database).build();
return beginTransaction(request);
@@ -719,7 +587,7 @@ public final BeginTransactionResponse beginTransaction(String database) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -742,7 +610,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -765,7 +633,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitResponse response = firestoreClient.commit(formattedDatabase, writes);
* }
@@ -778,7 +646,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CommitResponse commit(String database, List writes) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "commit");
+
CommitRequest request =
CommitRequest.newBuilder().setDatabase(database).addAllWrites(writes).build();
return commit(request);
@@ -792,7 +660,7 @@ public final CommitResponse commit(String database, List writes) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitRequest request = CommitRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -817,7 +685,7 @@ public final CommitResponse commit(CommitRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitRequest request = CommitRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -841,7 +709,7 @@ public final UnaryCallable commitCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* firestoreClient.rollback(formattedDatabase, transaction);
* }
@@ -853,7 +721,7 @@ public final UnaryCallable commitCallable() {
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void rollback(String database, ByteString transaction) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "rollback");
+
RollbackRequest request =
RollbackRequest.newBuilder().setDatabase(database).setTransaction(transaction).build();
rollback(request);
@@ -867,7 +735,7 @@ public final void rollback(String database, ByteString transaction) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* RollbackRequest request = RollbackRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -892,7 +760,7 @@ public final void rollback(RollbackRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* RollbackRequest request = RollbackRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -916,7 +784,7 @@ public final UnaryCallable rollbackCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* RunQueryRequest request = RunQueryRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -943,7 +811,7 @@ public final ServerStreamingCallable runQuery
* BidiStream<WriteRequest, WriteResponse> bidiStream =
* firestoreClient.writeCallable().call();
*
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* WriteRequest request = WriteRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -969,7 +837,7 @@ public final BidiStreamingCallable writeCallable()
* BidiStream<ListenRequest, ListenResponse> bidiStream =
* firestoreClient.listenCallable().call();
*
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ListenRequest request = ListenRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -992,7 +860,7 @@ public final BidiStreamingCallable listenCallable
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* for (String element : firestoreClient.listCollectionIds(formattedParent).iterateAll()) {
* // doThingsWith(element);
* }
@@ -1005,7 +873,6 @@ public final BidiStreamingCallable listenCallable
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListCollectionIdsPagedResponse listCollectionIds(String parent) {
- ANY_PATH_PATH_TEMPLATE.validate(parent, "listCollectionIds");
ListCollectionIdsRequest request =
ListCollectionIdsRequest.newBuilder().setParent(parent).build();
return listCollectionIds(request);
@@ -1019,7 +886,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(String parent) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -1044,7 +911,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -1069,7 +936,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
diff --git a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java
index ce92bacdefb1..776f34411c36 100644
--- a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java
+++ b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1beta1/FirestoreClient.java
@@ -27,7 +27,6 @@
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
-import com.google.api.pathtemplate.PathTemplate;
import com.google.cloud.firestore.v1beta1.stub.FirestoreStub;
import com.google.cloud.firestore.v1beta1.stub.FirestoreStubSettings;
import com.google.firestore.v1beta1.BatchGetDocumentsRequest;
@@ -145,137 +144,6 @@ public class FirestoreClient implements BackgroundResource {
private final FirestoreSettings settings;
private final FirestoreStub stub;
- private static final PathTemplate DATABASE_ROOT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}");
-
- private static final PathTemplate DOCUMENT_ROOT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}/documents");
-
- private static final PathTemplate DOCUMENT_PATH_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding(
- "projects/{project}/databases/{database}/documents/{document_path=**}");
-
- private static final PathTemplate ANY_PATH_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding(
- "projects/{project}/databases/{database}/documents/{document}/{any_path=**}");
-
- /** Formats a string containing the fully-qualified path to represent a database_root resource. */
- public static final String formatDatabaseRootName(String project, String database) {
- return DATABASE_ROOT_PATH_TEMPLATE.instantiate(
- "project", project,
- "database", database);
- }
-
- /** Formats a string containing the fully-qualified path to represent a document_root resource. */
- public static final String formatDocumentRootName(String project, String database) {
- return DOCUMENT_ROOT_PATH_TEMPLATE.instantiate(
- "project", project,
- "database", database);
- }
-
- /** Formats a string containing the fully-qualified path to represent a document_path resource. */
- public static final String formatDocumentPathName(
- String project, String database, String documentPath) {
- return DOCUMENT_PATH_PATH_TEMPLATE.instantiate(
- "project", project,
- "database", database,
- "document_path", documentPath);
- }
-
- /** Formats a string containing the fully-qualified path to represent a any_path resource. */
- public static final String formatAnyPathName(
- String project, String database, String document, String anyPath) {
- return ANY_PATH_PATH_TEMPLATE.instantiate(
- "project", project,
- "database", database,
- "document", document,
- "any_path", anyPath);
- }
-
- /**
- * Parses the project from the given fully-qualified path which represents a database_root
- * resource.
- */
- public static final String parseProjectFromDatabaseRootName(String databaseRootName) {
- return DATABASE_ROOT_PATH_TEMPLATE.parse(databaseRootName).get("project");
- }
-
- /**
- * Parses the database from the given fully-qualified path which represents a database_root
- * resource.
- */
- public static final String parseDatabaseFromDatabaseRootName(String databaseRootName) {
- return DATABASE_ROOT_PATH_TEMPLATE.parse(databaseRootName).get("database");
- }
-
- /**
- * Parses the project from the given fully-qualified path which represents a document_root
- * resource.
- */
- public static final String parseProjectFromDocumentRootName(String documentRootName) {
- return DOCUMENT_ROOT_PATH_TEMPLATE.parse(documentRootName).get("project");
- }
-
- /**
- * Parses the database from the given fully-qualified path which represents a document_root
- * resource.
- */
- public static final String parseDatabaseFromDocumentRootName(String documentRootName) {
- return DOCUMENT_ROOT_PATH_TEMPLATE.parse(documentRootName).get("database");
- }
-
- /**
- * Parses the project from the given fully-qualified path which represents a document_path
- * resource.
- */
- public static final String parseProjectFromDocumentPathName(String documentPathName) {
- return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("project");
- }
-
- /**
- * Parses the database from the given fully-qualified path which represents a document_path
- * resource.
- */
- public static final String parseDatabaseFromDocumentPathName(String documentPathName) {
- return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("database");
- }
-
- /**
- * Parses the document_path from the given fully-qualified path which represents a document_path
- * resource.
- */
- public static final String parseDocumentPathFromDocumentPathName(String documentPathName) {
- return DOCUMENT_PATH_PATH_TEMPLATE.parse(documentPathName).get("document_path");
- }
-
- /**
- * Parses the project from the given fully-qualified path which represents a any_path resource.
- */
- public static final String parseProjectFromAnyPathName(String anyPathName) {
- return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("project");
- }
-
- /**
- * Parses the database from the given fully-qualified path which represents a any_path resource.
- */
- public static final String parseDatabaseFromAnyPathName(String anyPathName) {
- return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("database");
- }
-
- /**
- * Parses the document from the given fully-qualified path which represents a any_path resource.
- */
- public static final String parseDocumentFromAnyPathName(String anyPathName) {
- return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("document");
- }
-
- /**
- * Parses the any_path from the given fully-qualified path which represents a any_path resource.
- */
- public static final String parseAnyPathFromAnyPathName(String anyPathName) {
- return ANY_PATH_PATH_TEMPLATE.parse(anyPathName).get("any_path");
- }
-
/** Constructs an instance of FirestoreClient with default settings. */
public static final FirestoreClient create() throws IOException {
return create(FirestoreSettings.newBuilder().build());
@@ -330,7 +198,7 @@ public FirestoreStub getStub() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* GetDocumentRequest request = GetDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -353,7 +221,7 @@ public final Document getDocument(GetDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* GetDocumentRequest request = GetDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -375,7 +243,7 @@ public final UnaryCallable getDocumentCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -402,7 +270,7 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -429,7 +297,7 @@ public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest reque
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* ListDocumentsRequest request = ListDocumentsRequest.newBuilder()
* .setParent(formattedParent)
@@ -462,7 +330,7 @@ public final UnaryCallable listDocu
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* String documentId = "";
* Document document = Document.newBuilder().build();
@@ -491,7 +359,7 @@ public final Document createDocument(CreateDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* String collectionId = "";
* String documentId = "";
* Document document = Document.newBuilder().build();
@@ -597,7 +465,7 @@ public final UnaryCallable updateDocumentCallab
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* firestoreClient.deleteDocument(formattedName);
* }
*
@@ -607,7 +475,7 @@ public final UnaryCallable updateDocumentCallab
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDocument(String name) {
- ANY_PATH_PATH_TEMPLATE.validate(name, "deleteDocument");
+
DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build();
deleteDocument(request);
}
@@ -620,7 +488,7 @@ public final void deleteDocument(String name) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -643,7 +511,7 @@ public final void deleteDocument(DeleteDocumentRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedName = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedName = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder()
* .setName(formattedName)
* .build();
@@ -668,7 +536,7 @@ public final UnaryCallable deleteDocumentCallable(
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<String> documents = new ArrayList<>();
* BatchGetDocumentsRequest request = BatchGetDocumentsRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -695,7 +563,7 @@ public final UnaryCallable deleteDocumentCallable(
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionResponse response = firestoreClient.beginTransaction(formattedDatabase);
* }
*
@@ -705,7 +573,7 @@ public final UnaryCallable deleteDocumentCallable(
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final BeginTransactionResponse beginTransaction(String database) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "beginTransaction");
+
BeginTransactionRequest request =
BeginTransactionRequest.newBuilder().setDatabase(database).build();
return beginTransaction(request);
@@ -719,7 +587,7 @@ public final BeginTransactionResponse beginTransaction(String database) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -742,7 +610,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* BeginTransactionRequest request = BeginTransactionRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -765,7 +633,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitResponse response = firestoreClient.commit(formattedDatabase, writes);
* }
@@ -778,7 +646,7 @@ public final BeginTransactionResponse beginTransaction(BeginTransactionRequest r
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CommitResponse commit(String database, List writes) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "commit");
+
CommitRequest request =
CommitRequest.newBuilder().setDatabase(database).addAllWrites(writes).build();
return commit(request);
@@ -792,7 +660,7 @@ public final CommitResponse commit(String database, List writes) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitRequest request = CommitRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -817,7 +685,7 @@ public final CommitResponse commit(CommitRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* List<Write> writes = new ArrayList<>();
* CommitRequest request = CommitRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -841,7 +709,7 @@ public final UnaryCallable commitCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* firestoreClient.rollback(formattedDatabase, transaction);
* }
@@ -853,7 +721,7 @@ public final UnaryCallable commitCallable() {
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void rollback(String database, ByteString transaction) {
- DATABASE_ROOT_PATH_TEMPLATE.validate(database, "rollback");
+
RollbackRequest request =
RollbackRequest.newBuilder().setDatabase(database).setTransaction(transaction).build();
rollback(request);
@@ -867,7 +735,7 @@ public final void rollback(String database, ByteString transaction) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* RollbackRequest request = RollbackRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -892,7 +760,7 @@ public final void rollback(RollbackRequest request) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ByteString transaction = ByteString.copyFromUtf8("");
* RollbackRequest request = RollbackRequest.newBuilder()
* .setDatabase(formattedDatabase)
@@ -916,7 +784,7 @@ public final UnaryCallable rollbackCallable() {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* RunQueryRequest request = RunQueryRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -943,7 +811,7 @@ public final ServerStreamingCallable runQuery
* BidiStream<WriteRequest, WriteResponse> bidiStream =
* firestoreClient.writeCallable().call();
*
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* WriteRequest request = WriteRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -969,7 +837,7 @@ public final BidiStreamingCallable writeCallable()
* BidiStream<ListenRequest, ListenResponse> bidiStream =
* firestoreClient.listenCallable().call();
*
- * String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ * String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
* ListenRequest request = ListenRequest.newBuilder()
* .setDatabase(formattedDatabase)
* .build();
@@ -992,7 +860,7 @@ public final BidiStreamingCallable listenCallable
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* for (String element : firestoreClient.listCollectionIds(formattedParent).iterateAll()) {
* // doThingsWith(element);
* }
@@ -1005,7 +873,6 @@ public final BidiStreamingCallable listenCallable
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListCollectionIdsPagedResponse listCollectionIds(String parent) {
- ANY_PATH_PATH_TEMPLATE.validate(parent, "listCollectionIds");
ListCollectionIdsRequest request =
ListCollectionIdsRequest.newBuilder().setParent(parent).build();
return listCollectionIds(request);
@@ -1019,7 +886,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(String parent) {
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -1044,7 +911,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
@@ -1069,7 +936,7 @@ public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsR
*
*
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
- * String formattedParent = FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ * String formattedParent = AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
* ListCollectionIdsRequest request = ListCollectionIdsRequest.newBuilder()
* .setParent(formattedParent)
* .build();
diff --git a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java
index 209551659f01..c180c1de0c8e 100644
--- a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java
+++ b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java
@@ -30,12 +30,14 @@
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.StatusCode;
import com.google.common.collect.Lists;
+import com.google.firestore.v1.AnyPathName;
import com.google.firestore.v1.BatchGetDocumentsRequest;
import com.google.firestore.v1.BatchGetDocumentsResponse;
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.DatabaseRootName;
import com.google.firestore.v1.DeleteDocumentRequest;
import com.google.firestore.v1.Document;
import com.google.firestore.v1.DocumentMask;
@@ -153,7 +155,7 @@ public void deleteDocumentTest() {
mockFirestore.addResponse(expectedResponse);
String formattedName =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.deleteDocument(formattedName);
@@ -176,7 +178,7 @@ public void deleteDocumentExceptionTest() throws Exception {
try {
String formattedName =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.deleteDocument(formattedName);
Assert.fail("No exception raised");
@@ -196,7 +198,7 @@ public void batchGetDocumentsTest() throws Exception {
.setTransaction(transaction)
.build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List documents = new ArrayList<>();
BatchGetDocumentsRequest request =
BatchGetDocumentsRequest.newBuilder()
@@ -220,7 +222,7 @@ public void batchGetDocumentsTest() throws Exception {
public void batchGetDocumentsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List documents = new ArrayList<>();
BatchGetDocumentsRequest request =
BatchGetDocumentsRequest.newBuilder()
@@ -252,7 +254,7 @@ public void beginTransactionTest() {
BeginTransactionResponse.newBuilder().setTransaction(transaction).build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
BeginTransactionResponse actualResponse = client.beginTransaction(formattedDatabase);
Assert.assertEquals(expectedResponse, actualResponse);
@@ -275,7 +277,7 @@ public void beginTransactionExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
client.beginTransaction(formattedDatabase);
Assert.fail("No exception raised");
@@ -290,7 +292,7 @@ public void commitTest() {
CommitResponse expectedResponse = CommitResponse.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List writes = new ArrayList<>();
CommitResponse actualResponse = client.commit(formattedDatabase, writes);
@@ -315,7 +317,7 @@ public void commitExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List writes = new ArrayList<>();
client.commit(formattedDatabase, writes);
@@ -331,7 +333,7 @@ public void rollbackTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ByteString transaction = ByteString.copyFromUtf8("-34");
client.rollback(formattedDatabase, transaction);
@@ -355,7 +357,7 @@ public void rollbackExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ByteString transaction = ByteString.copyFromUtf8("-34");
client.rollback(formattedDatabase, transaction);
@@ -377,7 +379,7 @@ public void runQueryTest() throws Exception {
.build();
mockFirestore.addResponse(expectedResponse);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
RunQueryRequest request = RunQueryRequest.newBuilder().setParent(formattedParent).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -396,7 +398,7 @@ public void runQueryExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
RunQueryRequest request = RunQueryRequest.newBuilder().setParent(formattedParent).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -422,7 +424,7 @@ public void writeTest() throws Exception {
WriteResponse expectedResponse =
WriteResponse.newBuilder().setStreamId(streamId).setStreamToken(streamToken).build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
WriteRequest request = WriteRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -443,7 +445,7 @@ public void writeTest() throws Exception {
public void writeExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
WriteRequest request = WriteRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -468,7 +470,7 @@ public void writeExceptionTest() throws Exception {
public void listenTest() throws Exception {
ListenResponse expectedResponse = ListenResponse.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ListenRequest request = ListenRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -489,7 +491,7 @@ public void listenTest() throws Exception {
public void listenExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ListenRequest request = ListenRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -523,7 +525,7 @@ public void listCollectionIdsTest() {
mockFirestore.addResponse(expectedResponse);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
ListCollectionIdsPagedResponse pagedListResponse = client.listCollectionIds(formattedParent);
@@ -550,7 +552,7 @@ public void listCollectionIdsExceptionTest() throws Exception {
try {
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.listCollectionIds(formattedParent);
Assert.fail("No exception raised");
diff --git a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1beta1/FirestoreClientTest.java b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1beta1/FirestoreClientTest.java
index 192c4f271da2..141015c02d8b 100644
--- a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1beta1/FirestoreClientTest.java
+++ b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1beta1/FirestoreClientTest.java
@@ -30,12 +30,14 @@
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.StatusCode;
import com.google.common.collect.Lists;
+import com.google.firestore.v1beta1.AnyPathName;
import com.google.firestore.v1beta1.BatchGetDocumentsRequest;
import com.google.firestore.v1beta1.BatchGetDocumentsResponse;
import com.google.firestore.v1beta1.BeginTransactionRequest;
import com.google.firestore.v1beta1.BeginTransactionResponse;
import com.google.firestore.v1beta1.CommitRequest;
import com.google.firestore.v1beta1.CommitResponse;
+import com.google.firestore.v1beta1.DatabaseRootName;
import com.google.firestore.v1beta1.DeleteDocumentRequest;
import com.google.firestore.v1beta1.Document;
import com.google.firestore.v1beta1.DocumentMask;
@@ -153,7 +155,7 @@ public void deleteDocumentTest() {
mockFirestore.addResponse(expectedResponse);
String formattedName =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.deleteDocument(formattedName);
@@ -176,7 +178,7 @@ public void deleteDocumentExceptionTest() throws Exception {
try {
String formattedName =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.deleteDocument(formattedName);
Assert.fail("No exception raised");
@@ -196,7 +198,7 @@ public void batchGetDocumentsTest() throws Exception {
.setTransaction(transaction)
.build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List documents = new ArrayList<>();
BatchGetDocumentsRequest request =
BatchGetDocumentsRequest.newBuilder()
@@ -220,7 +222,7 @@ public void batchGetDocumentsTest() throws Exception {
public void batchGetDocumentsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List documents = new ArrayList<>();
BatchGetDocumentsRequest request =
BatchGetDocumentsRequest.newBuilder()
@@ -252,7 +254,7 @@ public void beginTransactionTest() {
BeginTransactionResponse.newBuilder().setTransaction(transaction).build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
BeginTransactionResponse actualResponse = client.beginTransaction(formattedDatabase);
Assert.assertEquals(expectedResponse, actualResponse);
@@ -275,7 +277,7 @@ public void beginTransactionExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
client.beginTransaction(formattedDatabase);
Assert.fail("No exception raised");
@@ -290,7 +292,7 @@ public void commitTest() {
CommitResponse expectedResponse = CommitResponse.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List writes = new ArrayList<>();
CommitResponse actualResponse = client.commit(formattedDatabase, writes);
@@ -315,7 +317,7 @@ public void commitExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
List writes = new ArrayList<>();
client.commit(formattedDatabase, writes);
@@ -331,7 +333,7 @@ public void rollbackTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ByteString transaction = ByteString.copyFromUtf8("-34");
client.rollback(formattedDatabase, transaction);
@@ -355,7 +357,7 @@ public void rollbackExceptionTest() throws Exception {
mockFirestore.addException(exception);
try {
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ByteString transaction = ByteString.copyFromUtf8("-34");
client.rollback(formattedDatabase, transaction);
@@ -377,7 +379,7 @@ public void runQueryTest() throws Exception {
.build();
mockFirestore.addResponse(expectedResponse);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
RunQueryRequest request = RunQueryRequest.newBuilder().setParent(formattedParent).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -396,7 +398,7 @@ public void runQueryExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
RunQueryRequest request = RunQueryRequest.newBuilder().setParent(formattedParent).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -422,7 +424,7 @@ public void writeTest() throws Exception {
WriteResponse expectedResponse =
WriteResponse.newBuilder().setStreamId(streamId).setStreamToken(streamToken).build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
WriteRequest request = WriteRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -443,7 +445,7 @@ public void writeTest() throws Exception {
public void writeExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
WriteRequest request = WriteRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -468,7 +470,7 @@ public void writeExceptionTest() throws Exception {
public void listenTest() throws Exception {
ListenResponse expectedResponse = ListenResponse.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ListenRequest request = ListenRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -489,7 +491,7 @@ public void listenTest() throws Exception {
public void listenExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockFirestore.addException(exception);
- String formattedDatabase = FirestoreClient.formatDatabaseRootName("[PROJECT]", "[DATABASE]");
+ String formattedDatabase = DatabaseRootName.format("[PROJECT]", "[DATABASE]");
ListenRequest request = ListenRequest.newBuilder().setDatabase(formattedDatabase).build();
MockStreamObserver responseObserver = new MockStreamObserver<>();
@@ -523,7 +525,7 @@ public void listCollectionIdsTest() {
mockFirestore.addResponse(expectedResponse);
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
ListCollectionIdsPagedResponse pagedListResponse = client.listCollectionIds(formattedParent);
@@ -550,7 +552,7 @@ public void listCollectionIdsExceptionTest() throws Exception {
try {
String formattedParent =
- FirestoreClient.formatAnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
+ AnyPathName.format("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]");
client.listCollectionIds(formattedParent);
Assert.fail("No exception raised");
diff --git a/google-cloud-clients/google-cloud-firestore/synth.metadata b/google-cloud-clients/google-cloud-firestore/synth.metadata
index d7b290c01e37..fa4002ff894f 100644
--- a/google-cloud-clients/google-cloud-firestore/synth.metadata
+++ b/google-cloud-clients/google-cloud-firestore/synth.metadata
@@ -1,19 +1,19 @@
{
- "updateTime": "2019-01-16T08:42:18.702688Z",
+ "updateTime": "2019-02-08T08:45:45.169172Z",
"sources": [
{
"generator": {
"name": "artman",
- "version": "0.16.5",
- "dockerImage": "googleapis/artman@sha256:5a96c2c5c6f9570cc9556b63dc9ce1838777fd9166b5b64e43ad8e0ecee2fe2c"
+ "version": "0.16.10",
+ "dockerImage": "googleapis/artman@sha256:0954ba3e40d694e631bb2f39460d502a3d9f3a66d40b7a9a67f4b30012195beb"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
- "sha": "7a81902f287a4ac2ac130994889c80f87f91d035",
- "internalRef": "229452079"
+ "sha": "c0c7e28c5feb64f589078af01afc87a5fe0a6072",
+ "internalRef": "232905952"
}
}
],
@@ -27,6 +27,16 @@
"generator": "gapic",
"config": "google/firestore/artman_firestore.yaml"
}
+ },
+ {
+ "client": {
+ "source": "googleapis",
+ "apiName": "firestore",
+ "apiVersion": "v1",
+ "language": "java",
+ "generator": "gapic",
+ "config": "google/firestore/artman_firestore_v1.yaml"
+ }
}
]
}
\ No newline at end of file