From 892f3ef70fbfba4d26120d85b5858786c02c4c11 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 27 Apr 2022 17:48:36 +0000 Subject: [PATCH 1/2] feat:Enable RunQueryResponse.done PiperOrigin-RevId: 444879243 Source-Link: https://github.com/googleapis/googleapis/commit/c4b98bf382bf34458dc3a8d96d0bf91dbe75fa22 Source-Link: https://github.com/googleapis/googleapis-gen/commit/497ddcdeadceff35b285c6ea43f399e71dc313af Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDk3ZGRjZGVhZGNlZmYzNWIyODVjNmVhNDNmMzk5ZTcxZGMzMTNhZiJ9 --- owl-bot-staging/admin/v1/.eslintignore | 7 + owl-bot-staging/admin/v1/.eslintrc.json | 3 + owl-bot-staging/admin/v1/.gitignore | 14 + owl-bot-staging/admin/v1/.jsdoc.js | 55 + owl-bot-staging/admin/v1/.mocharc.js | 33 + owl-bot-staging/admin/v1/.prettierrc.js | 22 + owl-bot-staging/admin/v1/README.md | 1 + .../admin/v1/linkinator.config.json | 16 + owl-bot-staging/admin/v1/package.json | 64 + .../google/firestore/admin/v1/database.proto | 98 + .../google/firestore/admin/v1/field.proto | 100 + .../firestore/admin/v1/firestore_admin.proto | 459 ++++ .../google/firestore/admin/v1/index.proto | 157 ++ .../google/firestore/admin/v1/location.proto | 34 + .../google/firestore/admin/v1/operation.proto | 203 ++ .../v1/firestore_admin.create_index.js | 65 + .../v1/firestore_admin.delete_index.js | 59 + .../v1/firestore_admin.export_documents.js | 75 + .../v1/firestore_admin.get_database.js | 59 + .../generated/v1/firestore_admin.get_field.js | 59 + .../generated/v1/firestore_admin.get_index.js | 59 + .../v1/firestore_admin.import_documents.js | 73 + .../v1/firestore_admin.list_databases.js | 59 + .../v1/firestore_admin.list_fields.js | 79 + .../v1/firestore_admin.list_indexes.js | 75 + .../v1/firestore_admin.update_database.js | 63 + .../v1/firestore_admin.update_field.js | 64 + ...et_metadata.google.firestore.admin.v1.json | 547 +++++ owl-bot-staging/admin/v1/src/index.ts | 25 + .../admin/v1/src/v1/firestore_admin_client.ts | 1914 +++++++++++++++ .../src/v1/firestore_admin_client_config.json | 88 + .../v1/src/v1/firestore_admin_proto_list.json | 8 + .../admin/v1/src/v1/gapic_metadata.json | 151 ++ owl-bot-staging/admin/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../admin/v1/system-test/install.ts | 49 + .../admin/v1/test/gapic_firestore_admin_v1.ts | 2082 +++++++++++++++++ owl-bot-staging/admin/v1/tsconfig.json | 19 + owl-bot-staging/admin/v1/webpack.config.js | 64 + owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 64 + .../protos/google/firestore/v1/common.proto | 82 + .../protos/google/firestore/v1/document.proto | 149 ++ .../google/firestore/v1/firestore.proto | 912 ++++++++ .../v1/protos/google/firestore/v1/query.proto | 304 +++ .../v1/protos/google/firestore/v1/write.proto | 258 ++ .../v1/firestore.batch_get_documents.js | 90 + .../generated/v1/firestore.batch_write.js | 70 + .../v1/firestore.begin_transaction.js | 64 + .../samples/generated/v1/firestore.commit.js | 68 + .../generated/v1/firestore.create_document.js | 81 + .../generated/v1/firestore.delete_document.js | 64 + .../generated/v1/firestore.get_document.js | 74 + .../v1/firestore.list_collection_ids.js | 72 + .../generated/v1/firestore.list_documents.js | 107 + .../samples/generated/v1/firestore.listen.js | 75 + .../generated/v1/firestore.partition_query.js | 102 + .../generated/v1/firestore.rollback.js | 64 + .../generated/v1/firestore.run_query.js | 86 + .../generated/v1/firestore.update_document.js | 79 + .../samples/generated/v1/firestore.write.js | 95 + .../snippet_metadata.google.firestore.v1.json | 803 +++++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/firestore_client.ts | 1857 +++++++++++++++ .../v1/src/v1/firestore_client_config.json | 116 + .../v1/src/v1/firestore_proto_list.json | 7 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 165 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + owl-bot-staging/v1/test/gapic_firestore_v1.ts | 1928 +++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta1/.eslintignore | 7 + owl-bot-staging/v1beta1/.eslintrc.json | 3 + owl-bot-staging/v1beta1/.gitignore | 14 + owl-bot-staging/v1beta1/.jsdoc.js | 55 + owl-bot-staging/v1beta1/.mocharc.js | 33 + owl-bot-staging/v1beta1/.prettierrc.js | 22 + owl-bot-staging/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 16 + owl-bot-staging/v1beta1/package.json | 64 + .../google/firestore/v1beta1/common.proto | 83 + .../google/firestore/v1beta1/document.proto | 150 ++ .../google/firestore/v1beta1/firestore.proto | 900 +++++++ .../google/firestore/v1beta1/query.proto | 301 +++ .../google/firestore/v1beta1/write.proto | 259 ++ .../v1beta1/firestore.batch_get_documents.js | 90 + .../v1beta1/firestore.batch_write.js | 70 + .../v1beta1/firestore.begin_transaction.js | 64 + .../generated/v1beta1/firestore.commit.js | 68 + .../v1beta1/firestore.create_document.js | 81 + .../v1beta1/firestore.delete_document.js | 64 + .../v1beta1/firestore.get_document.js | 74 + .../v1beta1/firestore.list_collection_ids.js | 72 + .../v1beta1/firestore.list_documents.js | 107 + .../generated/v1beta1/firestore.listen.js | 75 + .../v1beta1/firestore.partition_query.js | 102 + .../generated/v1beta1/firestore.rollback.js | 64 + .../generated/v1beta1/firestore.run_query.js | 85 + .../v1beta1/firestore.update_document.js | 79 + .../generated/v1beta1/firestore.write.js | 95 + ...pet_metadata.google.firestore.v1beta1.json | 803 +++++++ owl-bot-staging/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/firestore_client.ts | 1855 +++++++++++++++ .../src/v1beta1/firestore_client_config.json | 99 + .../src/v1beta1/firestore_proto_list.json | 7 + .../v1beta1/src/v1beta1/gapic_metadata.json | 165 ++ owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + .../v1beta1/test/gapic_firestore_v1beta1.ts | 1928 +++++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 124 files changed, 23492 insertions(+) create mode 100644 owl-bot-staging/admin/v1/.eslintignore create mode 100644 owl-bot-staging/admin/v1/.eslintrc.json create mode 100644 owl-bot-staging/admin/v1/.gitignore create mode 100644 owl-bot-staging/admin/v1/.jsdoc.js create mode 100644 owl-bot-staging/admin/v1/.mocharc.js create mode 100644 owl-bot-staging/admin/v1/.prettierrc.js create mode 100644 owl-bot-staging/admin/v1/README.md create mode 100644 owl-bot-staging/admin/v1/linkinator.config.json create mode 100644 owl-bot-staging/admin/v1/package.json create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json create mode 100644 owl-bot-staging/admin/v1/src/index.ts create mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts create mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json create mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json create mode 100644 owl-bot-staging/admin/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/admin/v1/src/v1/index.ts create mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/admin/v1/system-test/install.ts create mode 100644 owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts create mode 100644 owl-bot-staging/admin/v1/tsconfig.json create mode 100644 owl-bot-staging/admin/v1/webpack.config.js create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/common.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/document.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/query.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/write.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.commit.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.listen.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.write.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/firestore_client.ts create mode 100644 owl-bot-staging/v1/src/v1/firestore_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/firestore_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_firestore_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1beta1/.eslintignore create mode 100644 owl-bot-staging/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1beta1/.gitignore create mode 100644 owl-bot-staging/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1beta1/README.md create mode 100644 owl-bot-staging/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1beta1/package.json create mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js create mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json create mode 100644 owl-bot-staging/v1beta1/src/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/owl-bot-staging/admin/v1/.eslintignore b/owl-bot-staging/admin/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/admin/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/admin/v1/.eslintrc.json b/owl-bot-staging/admin/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/admin/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/admin/v1/.gitignore b/owl-bot-staging/admin/v1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/admin/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/admin/v1/.jsdoc.js b/owl-bot-staging/admin/v1/.jsdoc.js new file mode 100644 index 000000000..accb86877 --- /dev/null +++ b/owl-bot-staging/admin/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/firestore-admin', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/admin/v1/.mocharc.js b/owl-bot-staging/admin/v1/.mocharc.js new file mode 100644 index 000000000..481c522b0 --- /dev/null +++ b/owl-bot-staging/admin/v1/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/admin/v1/.prettierrc.js b/owl-bot-staging/admin/v1/.prettierrc.js new file mode 100644 index 000000000..494e14786 --- /dev/null +++ b/owl-bot-staging/admin/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/admin/v1/README.md b/owl-bot-staging/admin/v1/README.md new file mode 100644 index 000000000..5d45b74ed --- /dev/null +++ b/owl-bot-staging/admin/v1/README.md @@ -0,0 +1 @@ +Admin: Nodejs Client diff --git a/owl-bot-staging/admin/v1/linkinator.config.json b/owl-bot-staging/admin/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/admin/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/admin/v1/package.json b/owl-bot-staging/admin/v1/package.json new file mode 100644 index 000000000..a2ffae1ee --- /dev/null +++ b/owl-bot-staging/admin/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/firestore-admin", + "version": "0.1.0", + "description": "Admin client for Node.js", + "repository": "googleapis/nodejs-admin", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google admin", + "admin", + "firestore admin" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto new file mode 100644 index 000000000..5b2cd7b6c --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto @@ -0,0 +1,98 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +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"; +option java_multiple_files = true; +option java_outer_classname = "DatabaseProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A Cloud Firestore Database. +// Currently only one database is allowed per cloud project; this database +// must have a `database_id` of '(default)'. +message Database { + option (google.api.resource) = { + type: "firestore.googleapis.com/Database" + pattern: "projects/{project}/databases/{database}" + style: DECLARATIVE_FRIENDLY + }; + + // The type of the database. + // See https://cloud.google.com/datastore/docs/firestore-or-datastore for + // information about how to choose. + enum DatabaseType { + // The default value. This value is used if the database type is omitted. + DATABASE_TYPE_UNSPECIFIED = 0; + + // Firestore Native Mode + FIRESTORE_NATIVE = 1; + + // Firestore in Datastore Mode. + DATASTORE_MODE = 2; + } + + // The type of concurrency control mode for transactions. + enum ConcurrencyMode { + // Not used. + CONCURRENCY_MODE_UNSPECIFIED = 0; + + // Use optimistic concurrency control by default. This setting is available + // for Cloud Firestore customers. + OPTIMISTIC = 1; + + // Use pessimistic concurrency control by default. This setting is available + // for Cloud Firestore customers. + // 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. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // The resource name of the Database. + // Format: `projects/{project}/databases/{database}` + string name = 1; + + // The location of the database. Available databases are listed at + // https://cloud.google.com/firestore/docs/locations. + string location_id = 9; + + // The type of the database. + // See https://cloud.google.com/datastore/docs/firestore-or-datastore for + // information about how to choose. + DatabaseType type = 10; + + // The concurrency control mode to use for this database. + ConcurrencyMode concurrency_mode = 15; + + // 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. + string etag = 99; +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto new file mode 100644 index 000000000..3e4224395 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto @@ -0,0 +1,100 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +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"; +option java_multiple_files = true; +option java_outer_classname = "FieldProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Represents a single field in the database. +// +// Fields are grouped by their "Collection Group", which represent all +// collections in the database with the same id. +message Field { + option (google.api.resource) = { + type: "firestore.googleapis.com/Field" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" + }; + + // The index configuration for this field. + message IndexConfig { + // The indexes supported for this field. + repeated Index indexes = 1; + + // Output only. When true, the `Field`'s index configuration is set from the + // configuration specified by the `ancestor_field`. + // When false, the `Field`'s index configuration is defined explicitly. + bool uses_ancestor_config = 2; + + // Output only. Specifies the resource name of the `Field` from which this field's + // index configuration is set (when `uses_ancestor_config` is true), + // or from which it *would* be set if this field had no index configuration + // (when `uses_ancestor_config` is false). + string ancestor_field = 3; + + // Output only + // When true, the `Field`'s index configuration is in the process of being + // reverted. Once complete, the index config will transition to the same + // state as the field specified by `ancestor_field`, at which point + // `uses_ancestor_config` will be `true` and `reverting` will be `false`. + bool reverting = 4; + } + + // 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]; + + // 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. + IndexConfig index_config = 2; +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto new file mode 100644 index 000000000..772ea214b --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto @@ -0,0 +1,459 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +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"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreAdminProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/CollectionGroup" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}" +}; + +// The Cloud Firestore Admin API. +// +// This API provides several administrative services for Cloud Firestore. +// +// Project, Database, Namespace, Collection, Collection Group, and Document are +// used as defined in the Google Cloud Firestore API. +// +// Operation: An Operation represents work being performed in the background. +// +// The index service manages Cloud Firestore indexes. +// +// Index creation is performed asynchronously. +// An Operation resource is created for each such asynchronous operation. +// The state of the operation (including any errors encountered) +// may be queried via the Operation resource. +// +// The Operations collection provides a record of actions performed for the +// specified Project (including any Operations in progress). Operations are not +// created directly but through calls on other collections or resources. +// +// An Operation that is done may be deleted so that it is no longer listed as +// part of the Operation collection. Operations are garbage collected after +// 30 days. By default, ListOperations will only return in progress and failed +// operations. To list completed operation, issue a ListOperations request with +// the filter `done: true`. +// +// Operations are created by service `FirestoreAdmin`, but are accessed via +// service `google.longrunning.Operations`. +service FirestoreAdmin { + option (google.api.default_host) = "firestore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] + // which may be used to track the status of the creation. The metadata for + // the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + body: "index" + }; + option (google.api.method_signature) = "parent,index"; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Lists composite indexes. + rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a composite index. + rpc GetIndex(GetIndexRequest) returns (Index) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a composite index. + rpc DeleteIndex(DeleteIndexRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the metadata and configuration for a Field. + rpc GetField(GetFieldRequest) returns (Field) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a field configuration. Currently, field updates apply only to + // single field index configuration. However, calls to + // [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid + // changing any configuration that the caller isn't aware of. The field mask + // should be specified as: `{ paths: "index_config" }`. + // + // This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to + // track the status of the field update. The metadata for + // the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. + // + // To configure the default field settings for the database, use + // the special `Field` with resource name: + // `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + rpc UpdateField(UpdateFieldRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}" + body: "field" + }; + option (google.api.method_signature) = "field"; + option (google.longrunning.operation_info) = { + response_type: "Field" + metadata_type: "FieldOperationMetadata" + }; + } + + // Lists the field configuration and metadata for this database. + // + // Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + // that have been explicitly overridden. To issue this query, call + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to + // `indexConfig.usesAncestorConfig:false` . + rpc ListFields(ListFieldsRequest) returns (ListFieldsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" + }; + option (google.api.method_signature) = "parent"; + } + + // Exports a copy of all or a subset of documents from Google Cloud Firestore + // to another storage system, such as Google Cloud Storage. Recent updates to + // documents may not be reflected in the export. The export occurs in the + // background and its progress can be monitored and managed via the + // Operation resource that is created. The output of an export may only be + // used once the associated operation is done. If an export operation is + // cancelled before completion it may leave partial data behind in Google + // Cloud Storage. + // + // For more details on export behavior and output format, refer to: + // https://cloud.google.com/firestore/docs/manage-data/export-import + rpc ExportDocuments(ExportDocumentsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*}:exportDocuments" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "ExportDocumentsResponse" + metadata_type: "ExportDocumentsMetadata" + }; + } + + // Imports documents into Google Cloud Firestore. Existing documents with the + // same name are overwritten. The import occurs in the background and its + // progress can be monitored and managed via the Operation resource that is + // created. If an ImportDocuments operation is cancelled, it is possible + // that a subset of the data has already been imported to Cloud Firestore. + rpc ImportDocuments(ImportDocumentsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*}:importDocuments" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportDocumentsMetadata" + }; + } + + // Gets information about a database. + rpc GetDatabase(GetDatabaseRequest) returns (Database) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List all the databases in the project. + rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/databases" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a database. + rpc UpdateDatabase(UpdateDatabaseRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{database.name=projects/*/databases/*}" + body: "database" + }; + option (google.api.method_signature) = "database,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "UpdateDatabaseMetadata" + }; + } +} + +// A request to list the Firestore Databases in all locations for a project. +message ListDatabasesRequest { + // Required. A parent name of the form + // `projects/{project_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; +} + +// The list of databases for a project. +message ListDatabasesResponse { + // The databases in the project. + repeated Database databases = 1; +} + +// The request for [FirestoreAdmin.GetDatabase][google.firestore.admin.v1.FirestoreAdmin.GetDatabase]. +message GetDatabaseRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; +} + +// The request for [FirestoreAdmin.UpdateDatabase][google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase]. +message UpdateDatabaseRequest { + // Required. The database to update. + Database database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Metadata related to the update database operation. +message UpdateDatabaseMetadata { + +} + +// The request for [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. +message CreateIndexRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // Required. The composite index to create. + Index index = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. +message ListIndexesRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // The filter to apply to list results. + string filter = 2; + + // The number of results to return. + int32 page_size = 3; + + // A page token, returned from a previous call to + // [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes], that may be used to get the next + // page of results. + string page_token = 4; +} + +// The response for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. +message ListIndexesResponse { + // The requested indexes. + repeated Index indexes = 1; + + // A page token that may be used to request another page of results. If blank, + // this is the last page. + string next_page_token = 2; +} + +// The request for [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex]. +message GetIndexRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Index" + } + ]; +} + +// The request for [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex]. +message DeleteIndexRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Index" + } + ]; +} + +// The request for [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. +message UpdateFieldRequest { + // Required. The field to be updated. + Field field = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask, relative to the field. If specified, only configuration specified + // by this field_mask will be updated in the field. + google.protobuf.FieldMask update_mask = 2; +} + +// The request for [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField]. +message GetFieldRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Field" + } + ]; +} + +// The request for [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. +message ListFieldsRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // The filter to apply to list results. Currently, + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields + // that have been explicitly overridden. To issue this query, call + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with a filter that includes + // `indexConfig.usesAncestorConfig:false` . + string filter = 2; + + // The number of results to return. + int32 page_size = 3; + + // A page token, returned from a previous call to + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields], that may be used to get the next + // page of results. + string page_token = 4; +} + +// The response for [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. +message ListFieldsResponse { + // The requested fields. + repeated Field fields = 1; + + // A page token that may be used to request another page of results. If blank, + // this is the last page. + string next_page_token = 2; +} + +// The request for [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. +message ExportDocumentsRequest { + // Required. Database to export. Should be of the form: + // `projects/{project_id}/databases/{database_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Which collection ids to export. Unspecified means all collections. + repeated string collection_ids = 2; + + // The output URI. Currently only supports Google Cloud Storage URIs of the + // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name + // of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional + // Google Cloud Storage namespace path. When + // choosing a name, be sure to consider Google Cloud Storage naming + // guidelines: https://cloud.google.com/storage/docs/naming. + // If the URI is a bucket (without a namespace path), a prefix will be + // generated based on the start time. + string output_uri_prefix = 3; +} + +// The request for [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. +message ImportDocumentsRequest { + // Required. Database to import into. Should be of the form: + // `projects/{project_id}/databases/{database_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Which collection ids to import. Unspecified means all collections included + // in the import. + repeated string collection_ids = 2; + + // Location of the exported files. + // This must match the output_uri_prefix of an ExportDocumentsResponse from + // an export that has completed successfully. + // See: + // [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. + string input_uri_prefix = 3; +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto new file mode 100644 index 000000000..7e330a99c --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto @@ -0,0 +1,157 @@ +// Copyright 2021 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 +// +// http://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. + +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"; +option java_multiple_files = true; +option java_outer_classname = "IndexProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Cloud Firestore indexes enable simple and complex queries against +// documents in a database. +message Index { + option (google.api.resource) = { + type: "firestore.googleapis.com/Index" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" + }; + + // A field in an index. + // The field_path describes which field is indexed, the value_mode describes + // how the field value is indexed. + message IndexField { + // The supported orderings. + enum Order { + // The ordering is unspecified. Not a valid option. + ORDER_UNSPECIFIED = 0; + + // The field is ordered by ascending field value. + ASCENDING = 1; + + // The field is ordered by descending field value. + DESCENDING = 2; + } + + // The supported array value configurations. + enum ArrayConfig { + // The index does not support additional array queries. + ARRAY_CONFIG_UNSPECIFIED = 0; + + // The index supports array containment queries. + CONTAINS = 1; + } + + // Can be __name__. + // For single field indexes, this must match the name of the field or may + // be omitted. + string field_path = 1; + + // How the field value is indexed. + oneof value_mode { + // Indicates that this field supports ordering by the specified order or + // comparing using =, !=, <, <=, >, >=. + Order order = 2; + + // Indicates that this field supports operations on `array_value`s. + ArrayConfig array_config = 3; + } + } + + // 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 + // will transition to the `NEEDS_REPAIR` state. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The index is being created. + // There is an active long-running operation for the index. + // The index is updated when writing a document. + // Some index data may exist. + CREATING = 1; + + // The index is ready to be used. + // The index is updated when writing a document. + // The index is fully populated from all stored documents it applies to. + READY = 2; + + // The index was being created, but something went wrong. + // There is no active long-running operation for the index, + // and the most recently finished long-running operation failed. + // The index is not updated when writing a document. + // Some index data may exist. + // Use the google.longrunning.Operations API to determine why the operation + // that last attempted to create this index failed, then re-create the + // index. + NEEDS_REPAIR = 3; + } + + // Output only. A server defined name for this index. + // The form of this name for composite indexes will be: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` + // For single field indexes, this field will be empty. + string name = 1; + + // 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 same collection id. + // + // Indexes with a collection group query scope specified allow queries against + // all collections descended from a specific document, specified at query + // time, and that have the same collection id as this index. + QueryScope query_scope = 2; + + // The fields supported by this index. + // + // For composite indexes, this is always 2 or more fields. + // The last field entry is always for the field path `__name__`. If, on + // creation, `__name__` was not specified as the last field, it will be added + // automatically with the same direction as that of the last field defined. If + // the final field in a composite index is not directional, the `__name__` + // will be ordered ASCENDING (unless explicitly specified). + // + // For single field indexes, this will always be exactly one entry with a + // field path equal to the field path of the associated field. + repeated IndexField fields = 3; + + // Output only. The serving state of the index. + State state = 4; +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto new file mode 100644 index 000000000..ce34de36b --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto @@ -0,0 +1,34 @@ +// Copyright 2021 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 +// +// http://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. + +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; +option java_outer_classname = "LocationProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// The metadata message for [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata]. +message LocationMetadata { + +} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto new file mode 100644 index 000000000..1b918fdb1 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto @@ -0,0 +1,203 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +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"; +option java_multiple_files = true; +option java_outer_classname = "OperationProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from +// [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. +message IndexOperationMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The index resource that this operation is acting on. For example: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string index = 3; + + // The state of the operation. + OperationState state = 4; + + // The progress, in documents, of this operation. + Progress progress_documents = 5; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 6; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from +// [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. +message FieldOperationMetadata { + // Information about an index configuration change. + message IndexConfigDelta { + // Specifies how the index is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The single field index is being added. + ADD = 1; + + // The single field index is being removed. + REMOVE = 2; + } + + // Specifies how the index is changing. + ChangeType change_type = 1; + + // The index being changed. + Index index = 2; + } + + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The field resource that this operation is acting on. For example: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` + string field = 3; + + // A list of [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta], which describe the intent of this + // operation. + repeated IndexConfigDelta index_config_deltas = 4; + + // The state of the operation. + OperationState state = 5; + + // The progress, in documents, of this operation. + Progress progress_documents = 6; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 7; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from +// [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. +message ExportDocumentsMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The state of the export operation. + OperationState operation_state = 3; + + // The progress, in documents, of this operation. + Progress progress_documents = 4; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 5; + + // Which collection ids are being exported. + repeated string collection_ids = 6; + + // Where the entities are being exported to. + string output_uri_prefix = 7; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from +// [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. +message ImportDocumentsMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The state of the import operation. + OperationState operation_state = 3; + + // The progress, in documents, of this operation. + Progress progress_documents = 4; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 5; + + // Which collection ids are being imported. + repeated string collection_ids = 6; + + // The location of the documents being imported. + string input_uri_prefix = 7; +} + +// Returned in the [google.longrunning.Operation][google.longrunning.Operation] response field. +message ExportDocumentsResponse { + // Location of the output files. This can be used to begin an import + // into Cloud Firestore (this project or another project) after the operation + // completes successfully. + string output_uri_prefix = 1; +} + +// Describes the state of the operation. +enum OperationState { + // Unspecified. + OPERATION_STATE_UNSPECIFIED = 0; + + // Request is being prepared for processing. + INITIALIZING = 1; + + // Request is actively being processed. + PROCESSING = 2; + + // Request is in the process of being cancelled after user called + // google.longrunning.Operations.CancelOperation on the operation. + CANCELLING = 3; + + // Request has been processed and is in its finalization stage. + FINALIZING = 4; + + // Request has completed successfully. + SUCCESSFUL = 5; + + // Request has finished being processed, but encountered an error. + FAILED = 6; + + // Request has finished being cancelled after user called + // google.longrunning.Operations.CancelOperation. + CANCELLED = 7; +} + +// Describes the progress of the operation. +// Unit of work is generic and must be interpreted based on where [Progress][google.firestore.admin.v1.Progress] +// is used. +message Progress { + // The amount of work estimated. + int64 estimated_work = 1; + + // The amount of work completed. + int64 completed_work = 2; +} diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js new file mode 100644 index 000000000..1ccd828d2 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js @@ -0,0 +1,65 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, index) { + // [START firestore_v1_generated_FirestoreAdmin_CreateIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + */ + // const parent = 'abc123' + /** + * Required. The composite index to create. + */ + // const index = {} + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callCreateIndex() { + // Construct request + const request = { + parent, + index, + }; + + // Run request + const [operation] = await adminClient.createIndex(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateIndex(); + // [END firestore_v1_generated_FirestoreAdmin_CreateIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js new file mode 100644 index 000000000..2002ee5fa --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_DeleteIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + */ + // const name = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callDeleteIndex() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await adminClient.deleteIndex(request); + console.log(response); + } + + callDeleteIndex(); + // [END firestore_v1_generated_FirestoreAdmin_DeleteIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js new file mode 100644 index 000000000..784a6eb74 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js @@ -0,0 +1,75 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_ExportDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Database to export. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + */ + // const name = 'abc123' + /** + * Which collection ids to export. Unspecified means all collections. + */ + // const collectionIds = 'abc123' + /** + * The output URI. Currently only supports Google Cloud Storage URIs of the + * form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the name + * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional + * Google Cloud Storage namespace path. When + * choosing a name, be sure to consider Google Cloud Storage naming + * guidelines: https://cloud.google.com/storage/docs/naming. + * If the URI is a bucket (without a namespace path), a prefix will be + * generated based on the start time. + */ + // const outputUriPrefix = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callExportDocuments() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await adminClient.exportDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callExportDocuments(); + // [END firestore_v1_generated_FirestoreAdmin_ExportDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js new file mode 100644 index 000000000..a07ae055b --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_GetDatabase_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}` + */ + // const name = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callGetDatabase() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await adminClient.getDatabase(request); + console.log(response); + } + + callGetDatabase(); + // [END firestore_v1_generated_FirestoreAdmin_GetDatabase_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js new file mode 100644 index 000000000..00f78dd3c --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_GetField_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` + */ + // const name = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callGetField() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await adminClient.getField(request); + console.log(response); + } + + callGetField(); + // [END firestore_v1_generated_FirestoreAdmin_GetField_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js new file mode 100644 index 000000000..792356c35 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_GetIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + */ + // const name = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callGetIndex() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await adminClient.getIndex(request); + console.log(response); + } + + callGetIndex(); + // [END firestore_v1_generated_FirestoreAdmin_GetIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js new file mode 100644 index 000000000..1135c861e --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js @@ -0,0 +1,73 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_FirestoreAdmin_ImportDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Database to import into. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + */ + // const name = 'abc123' + /** + * Which collection ids to import. Unspecified means all collections included + * in the import. + */ + // const collectionIds = 'abc123' + /** + * Location of the exported files. + * This must match the output_uri_prefix of an ExportDocumentsResponse from + * an export that has completed successfully. + * See: + * google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix. + */ + // const inputUriPrefix = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callImportDocuments() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await adminClient.importDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportDocuments(); + // [END firestore_v1_generated_FirestoreAdmin_ImportDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js new file mode 100644 index 000000000..e5fada31b --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js @@ -0,0 +1,59 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_FirestoreAdmin_ListDatabases_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}` + */ + // const parent = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callListDatabases() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await adminClient.listDatabases(request); + console.log(response); + } + + callListDatabases(); + // [END firestore_v1_generated_FirestoreAdmin_ListDatabases_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js new file mode 100644 index 000000000..b7814b88d --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js @@ -0,0 +1,79 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_FirestoreAdmin_ListFields_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + */ + // const parent = 'abc123' + /** + * The filter to apply to list results. Currently, + * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields only supports listing fields + * that have been explicitly overridden. To issue this query, call + * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields with a filter that includes + * `indexConfig.usesAncestorConfig:false` . + */ + // const filter = 'abc123' + /** + * The number of results to return. + */ + // const pageSize = 1234 + /** + * A page token, returned from a previous call to + * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields, that may be used to get the next + * page of results. + */ + // const pageToken = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callListFields() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await adminClient.listFieldsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListFields(); + // [END firestore_v1_generated_FirestoreAdmin_ListFields_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js new file mode 100644 index 000000000..460f77d79 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js @@ -0,0 +1,75 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_FirestoreAdmin_ListIndexes_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + */ + // const parent = 'abc123' + /** + * The filter to apply to list results. + */ + // const filter = 'abc123' + /** + * The number of results to return. + */ + // const pageSize = 1234 + /** + * A page token, returned from a previous call to + * FirestoreAdmin.ListIndexes google.firestore.admin.v1.FirestoreAdmin.ListIndexes, that may be used to get the next + * page of results. + */ + // const pageToken = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callListIndexes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await adminClient.listIndexesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListIndexes(); + // [END firestore_v1_generated_FirestoreAdmin_ListIndexes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js new file mode 100644 index 000000000..c83a53088 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js @@ -0,0 +1,63 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database to update. + */ + // const database = {} + /** + * The list of fields to be updated. + */ + // const updateMask = {} + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callUpdateDatabase() { + // Construct request + const request = { + database, + }; + + // Run request + const [operation] = await adminClient.updateDatabase(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateDatabase(); + // [END firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js new file mode 100644 index 000000000..65eaa42d5 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(field) { + // [START firestore_v1_generated_FirestoreAdmin_UpdateField_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The field to be updated. + */ + // const field = {} + /** + * A mask, relative to the field. If specified, only configuration specified + * by this field_mask will be updated in the field. + */ + // const updateMask = {} + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callUpdateField() { + // Construct request + const request = { + field, + }; + + // Run request + const [operation] = await adminClient.updateField(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateField(); + // [END firestore_v1_generated_FirestoreAdmin_UpdateField_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json new file mode 100644 index 000000000..9ecd3a140 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json @@ -0,0 +1,547 @@ +{ + "clientLibrary": { + "name": "nodejs-admin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.firestore.admin.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_CreateIndex_async", + "title": "FirestoreAdmin createIndex Sample", + "origin": "API_DEFINITION", + "description": " Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the creation. The metadata for the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].", + "canonical": true, + "file": "firestore_admin.create_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateIndex", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "index", + "type": ".google.firestore.admin.v1.Index" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "CreateIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateIndex", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_ListIndexes_async", + "title": "FirestoreAdmin listIndexes Sample", + "origin": "API_DEFINITION", + "description": " Lists composite indexes.", + "canonical": true, + "file": "firestore_admin.list_indexes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListIndexes", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListIndexes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.ListIndexesResponse", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "ListIndexes", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListIndexes", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_GetIndex_async", + "title": "FirestoreAdmin getIndex Sample", + "origin": "API_DEFINITION", + "description": " Gets a composite index.", + "canonical": true, + "file": "firestore_admin.get_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetIndex", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.Index", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "GetIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetIndex", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_DeleteIndex_async", + "title": "FirestoreAdmin deleteIndex Sample", + "origin": "API_DEFINITION", + "description": " Deletes a composite index.", + "canonical": true, + "file": "firestore_admin.delete_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.DeleteIndex", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "DeleteIndex", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.DeleteIndex", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_GetField_async", + "title": "FirestoreAdmin getField Sample", + "origin": "API_DEFINITION", + "description": " Gets the metadata and configuration for a Field.", + "canonical": true, + "file": "firestore_admin.get_field.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetField", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetField", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.Field", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "GetField", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetField", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_UpdateField_async", + "title": "FirestoreAdmin updateField Sample", + "origin": "API_DEFINITION", + "description": " Updates a field configuration. Currently, field updates apply only to single field index configuration. However, calls to [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid changing any configuration that the caller isn't aware of. The field mask should be specified as: `{ paths: \"index_config\" }`. This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the field update. The metadata for the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.", + "canonical": true, + "file": "firestore_admin.update_field.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateField", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateField", + "async": true, + "parameters": [ + { + "name": "field", + "type": ".google.firestore.admin.v1.Field" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "UpdateField", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateField", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_ListFields_async", + "title": "FirestoreAdmin listFields Sample", + "origin": "API_DEFINITION", + "description": " Lists the field configuration and metadata for this database. Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false` .", + "canonical": true, + "file": "firestore_admin.list_fields.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListFields", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListFields", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.ListFieldsResponse", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "ListFields", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListFields", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_ExportDocuments_async", + "title": "FirestoreAdmin exportDocuments Sample", + "origin": "API_DEFINITION", + "description": " Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import", + "canonical": true, + "file": "firestore_admin.export_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportDocuments", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ExportDocuments", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "collection_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "output_uri_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "ExportDocuments", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ExportDocuments", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_ImportDocuments_async", + "title": "FirestoreAdmin importDocuments Sample", + "origin": "API_DEFINITION", + "description": " Imports documents into Google Cloud Firestore. Existing documents with the same name are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.", + "canonical": true, + "file": "firestore_admin.import_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportDocuments", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ImportDocuments", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "collection_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "input_uri_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "ImportDocuments", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ImportDocuments", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_GetDatabase_async", + "title": "FirestoreAdmin getDatabase Sample", + "origin": "API_DEFINITION", + "description": " Gets information about a database.", + "canonical": true, + "file": "firestore_admin.get_database.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetDatabase", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.Database", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "GetDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetDatabase", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_ListDatabases_async", + "title": "FirestoreAdmin listDatabases Sample", + "origin": "API_DEFINITION", + "description": " List all the databases in the project.", + "canonical": true, + "file": "firestore_admin.list_databases.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDatabases", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListDatabases", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.admin.v1.ListDatabasesResponse", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "ListDatabases", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListDatabases", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async", + "title": "FirestoreAdmin updateDatabase Sample", + "origin": "API_DEFINITION", + "description": " Updates a database.", + "canonical": true, + "file": "firestore_admin.update_database.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase", + "async": true, + "parameters": [ + { + "name": "database", + "type": ".google.firestore.admin.v1.Database" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "UpdateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase", + "service": { + "shortName": "FirestoreAdmin", + "fullName": "google.firestore.admin.v1.FirestoreAdmin" + } + } + } + } + ] +} diff --git a/owl-bot-staging/admin/v1/src/index.ts b/owl-bot-staging/admin/v1/src/index.ts new file mode 100644 index 000000000..d5c1e4e93 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const FirestoreAdminClient = v1.FirestoreAdminClient; +type FirestoreAdminClient = v1.FirestoreAdminClient; +export {v1, FirestoreAdminClient}; +export default {v1, FirestoreAdminClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts new file mode 100644 index 000000000..62d7cfbbd --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts @@ -0,0 +1,1914 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/firestore_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './firestore_admin_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * The Cloud Firestore Admin API. + * + * This API provides several administrative services for Cloud Firestore. + * + * Project, Database, Namespace, Collection, Collection Group, and Document are + * used as defined in the Google Cloud Firestore API. + * + * Operation: An Operation represents work being performed in the background. + * + * The index service manages Cloud Firestore indexes. + * + * Index creation is performed asynchronously. + * An Operation resource is created for each such asynchronous operation. + * The state of the operation (including any errors encountered) + * may be queried via the Operation resource. + * + * The Operations collection provides a record of actions performed for the + * specified Project (including any Operations in progress). Operations are not + * created directly but through calls on other collections or resources. + * + * An Operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. Operations are garbage collected after + * 30 days. By default, ListOperations will only return in progress and failed + * operations. To list completed operation, issue a ListOperations request with + * the filter `done: true`. + * + * Operations are created by service `FirestoreAdmin`, but are accessed via + * service `google.longrunning.Operations`. + * @class + * @memberof v1 + */ +export class FirestoreAdminClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + firestoreAdminStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreAdminClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FirestoreAdminClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + collectionGroupPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}' + ), + databasePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/databases/{database}' + ), + fieldPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}' + ), + indexPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listIndexes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes'), + listFields: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'fields') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const createIndexResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Index') as gax.protobuf.Type; + const createIndexMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; + const updateFieldResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Field') as gax.protobuf.Type; + const updateFieldMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.FieldOperationMetadata') as gax.protobuf.Type; + const exportDocumentsResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ExportDocumentsResponse') as gax.protobuf.Type; + const exportDocumentsMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ExportDocumentsMetadata') as gax.protobuf.Type; + const importDocumentsResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const importDocumentsMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.ImportDocumentsMetadata') as gax.protobuf.Type; + const updateDatabaseResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Database') as gax.protobuf.Type; + const updateDatabaseMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.UpdateDatabaseMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createIndex: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createIndexResponse.decode.bind(createIndexResponse), + createIndexMetadata.decode.bind(createIndexMetadata)), + updateField: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateFieldResponse.decode.bind(updateFieldResponse), + updateFieldMetadata.decode.bind(updateFieldMetadata)), + exportDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + exportDocumentsResponse.decode.bind(exportDocumentsResponse), + exportDocumentsMetadata.decode.bind(exportDocumentsMetadata)), + importDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importDocumentsResponse.decode.bind(importDocumentsResponse), + importDocumentsMetadata.decode.bind(importDocumentsMetadata)), + updateDatabase: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateDatabaseResponse.decode.bind(updateDatabaseResponse), + updateDatabaseMetadata.decode.bind(updateDatabaseMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.firestore.admin.v1.FirestoreAdmin', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreAdminStub) { + return this.firestoreAdminStub; + } + + // Put together the "service stub" for + // google.firestore.admin.v1.FirestoreAdmin. + this.firestoreAdminStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.firestore.admin.v1.FirestoreAdmin') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.firestore.admin.v1.FirestoreAdmin, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreAdminStubMethods = + ['createIndex', 'listIndexes', 'getIndex', 'deleteIndex', 'getField', 'updateField', 'listFields', 'exportDocuments', 'importDocuments', 'getDatabase', 'listDatabases', 'updateDatabase']; + for (const methodName of firestoreAdminStubMethods) { + const callPromise = this.firestoreAdminStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.firestoreAdminStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a composite index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Index]{@link google.firestore.admin.v1.Index}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.get_index.js + * region_tag:firestore_v1_generated_FirestoreAdmin_GetIndex_async + */ + getIndex( + request?: protos.google.firestore.admin.v1.IGetIndexRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|undefined, {}|undefined + ]>; + getIndex( + request: protos.google.firestore.admin.v1.IGetIndexRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): void; + getIndex( + request: protos.google.firestore.admin.v1.IGetIndexRequest, + callback: Callback< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): void; + getIndex( + request?: protos.google.firestore.admin.v1.IGetIndexRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.admin.v1.IIndex, + protos.google.firestore.admin.v1.IGetIndexRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getIndex(request, options, callback); + } +/** + * Deletes a composite index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.delete_index.js + * region_tag:firestore_v1_generated_FirestoreAdmin_DeleteIndex_async + */ + deleteIndex( + request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|undefined, {}|undefined + ]>; + deleteIndex( + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, + {}|null|undefined>): void; + deleteIndex( + request: protos.google.firestore.admin.v1.IDeleteIndexRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, + {}|null|undefined>): void; + deleteIndex( + request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.admin.v1.IDeleteIndexRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteIndex(request, options, callback); + } +/** + * Gets the metadata and configuration for a Field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Field]{@link google.firestore.admin.v1.Field}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.get_field.js + * region_tag:firestore_v1_generated_FirestoreAdmin_GetField_async + */ + getField( + request?: protos.google.firestore.admin.v1.IGetFieldRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|undefined, {}|undefined + ]>; + getField( + request: protos.google.firestore.admin.v1.IGetFieldRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, + {}|null|undefined>): void; + getField( + request: protos.google.firestore.admin.v1.IGetFieldRequest, + callback: Callback< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, + {}|null|undefined>): void; + getField( + request?: protos.google.firestore.admin.v1.IGetFieldRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.admin.v1.IField, + protos.google.firestore.admin.v1.IGetFieldRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getField(request, options, callback); + } +/** + * Gets information about a database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A name of the form + * `projects/{project_id}/databases/{database_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Database]{@link google.firestore.admin.v1.Database}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.get_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_GetDatabase_async + */ + getDatabase( + request?: protos.google.firestore.admin.v1.IGetDatabaseRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|undefined, {}|undefined + ]>; + getDatabase( + request: protos.google.firestore.admin.v1.IGetDatabaseRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): void; + getDatabase( + request: protos.google.firestore.admin.v1.IGetDatabaseRequest, + callback: Callback< + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): void; + getDatabase( + request?: protos.google.firestore.admin.v1.IGetDatabaseRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.admin.v1.IDatabase, + protos.google.firestore.admin.v1.IGetDatabaseRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getDatabase(request, options, callback); + } +/** + * List all the databases in the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListDatabasesResponse]{@link google.firestore.admin.v1.ListDatabasesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.list_databases.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ListDatabases_async + */ + listDatabases( + request?: protos.google.firestore.admin.v1.IListDatabasesRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|undefined, {}|undefined + ]>; + listDatabases( + request: protos.google.firestore.admin.v1.IListDatabasesRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, + {}|null|undefined>): void; + listDatabases( + request: protos.google.firestore.admin.v1.IListDatabasesRequest, + callback: Callback< + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, + {}|null|undefined>): void; + listDatabases( + request?: protos.google.firestore.admin.v1.IListDatabasesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.admin.v1.IListDatabasesResponse, + protos.google.firestore.admin.v1.IListDatabasesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listDatabases(request, options, callback); + } + +/** + * Creates a composite index. This returns a {@link google.longrunning.Operation|google.longrunning.Operation} + * which may be used to track the status of the creation. The metadata for + * the operation will be the type {@link google.firestore.admin.v1.IndexOperationMetadata|IndexOperationMetadata}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {google.firestore.admin.v1.Index} request.index + * Required. The composite index to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_index.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateIndex_async + */ + createIndex( + request?: protos.google.firestore.admin.v1.ICreateIndexRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createIndex( + request: protos.google.firestore.admin.v1.ICreateIndexRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createIndex( + request: protos.google.firestore.admin.v1.ICreateIndexRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createIndex( + request?: protos.google.firestore.admin.v1.ICreateIndexRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createIndex(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createIndex()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_index.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateIndex_async + */ + async checkCreateIndexProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a field configuration. Currently, field updates apply only to + * single field index configuration. However, calls to + * {@link google.firestore.admin.v1.FirestoreAdmin.UpdateField|FirestoreAdmin.UpdateField} should provide a field mask to avoid + * changing any configuration that the caller isn't aware of. The field mask + * should be specified as: `{ paths: "index_config" }`. + * + * This call returns a {@link google.longrunning.Operation|google.longrunning.Operation} which may be used to + * track the status of the field update. The metadata for + * the operation will be the type {@link google.firestore.admin.v1.FieldOperationMetadata|FieldOperationMetadata}. + * + * To configure the default field settings for the database, use + * the special `Field` with resource name: + * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.admin.v1.Field} request.field + * Required. The field to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask, relative to the field. If specified, only configuration specified + * by this field_mask will be updated in the field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.update_field.js + * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateField_async + */ + updateField( + request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateField( + request: protos.google.firestore.admin.v1.IUpdateFieldRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateField( + request: protos.google.firestore.admin.v1.IUpdateFieldRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateField( + request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'field.name': request.field!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateField(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateField()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.update_field.js + * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateField_async + */ + async checkUpdateFieldProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateField, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Exports a copy of all or a subset of documents from Google Cloud Firestore + * to another storage system, such as Google Cloud Storage. Recent updates to + * documents may not be reflected in the export. The export occurs in the + * background and its progress can be monitored and managed via the + * Operation resource that is created. The output of an export may only be + * used once the associated operation is done. If an export operation is + * cancelled before completion it may leave partial data behind in Google + * Cloud Storage. + * + * For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Database to export. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.collectionIds + * Which collection ids to export. Unspecified means all collections. + * @param {string} request.outputUriPrefix + * The output URI. Currently only supports Google Cloud Storage URIs of the + * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name + * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional + * Google Cloud Storage namespace path. When + * choosing a name, be sure to consider Google Cloud Storage naming + * guidelines: https://cloud.google.com/storage/docs/naming. + * If the URI is a bucket (without a namespace path), a prefix will be + * generated based on the start time. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.export_documents.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ExportDocuments_async + */ + exportDocuments( + request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + exportDocuments( + request: protos.google.firestore.admin.v1.IExportDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportDocuments( + request: protos.google.firestore.admin.v1.IExportDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportDocuments( + request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.exportDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `exportDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.export_documents.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ExportDocuments_async + */ + async checkExportDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Imports documents into Google Cloud Firestore. Existing documents with the + * same name are overwritten. The import occurs in the background and its + * progress can be monitored and managed via the Operation resource that is + * created. If an ImportDocuments operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Firestore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Database to import into. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.collectionIds + * Which collection ids to import. Unspecified means all collections included + * in the import. + * @param {string} request.inputUriPrefix + * Location of the exported files. + * This must match the output_uri_prefix of an ExportDocumentsResponse from + * an export that has completed successfully. + * See: + * {@link google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix|google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.import_documents.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ImportDocuments_async + */ + importDocuments( + request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importDocuments( + request: protos.google.firestore.admin.v1.IImportDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request: protos.google.firestore.admin.v1.IImportDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importDocuments( + request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.importDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.import_documents.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ImportDocuments_async + */ + async checkImportDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a database. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.admin.v1.Database} request.database + * Required. The database to update. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.update_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async + */ + updateDatabase( + request?: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateDatabase( + request: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateDatabase( + request: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateDatabase( + request?: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database.name': request.database!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateDatabase(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateDatabase()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.update_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async + */ + async checkUpdateDatabaseProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateDatabase, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists composite indexes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Index]{@link google.firestore.admin.v1.Index}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listIndexes( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IIndex[], + protos.google.firestore.admin.v1.IListIndexesRequest|null, + protos.google.firestore.admin.v1.IListIndexesResponse + ]>; + listIndexes( + request: protos.google.firestore.admin.v1.IListIndexesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.firestore.admin.v1.IIndex>): void; + listIndexes( + request: protos.google.firestore.admin.v1.IListIndexesRequest, + callback: PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.firestore.admin.v1.IIndex>): void; + listIndexes( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.firestore.admin.v1.IIndex>, + callback?: PaginationCallback< + protos.google.firestore.admin.v1.IListIndexesRequest, + protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.firestore.admin.v1.IIndex>): + Promise<[ + protos.google.firestore.admin.v1.IIndex[], + protos.google.firestore.admin.v1.IListIndexesRequest|null, + protos.google.firestore.admin.v1.IListIndexesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listIndexes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listIndexesStream( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listIndexes.createStream( + this.innerApiCalls.listIndexes as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listIndexes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Index]{@link google.firestore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.list_indexes.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ListIndexes_async + */ + listIndexesAsync( + request?: protos.google.firestore.admin.v1.IListIndexesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listIndexes.asyncIterate( + this.innerApiCalls['listIndexes'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Lists the field configuration and metadata for this database. + * + * Currently, {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields + * that have been explicitly overridden. To issue this query, call + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with the filter set to + * `indexConfig.usesAncestorConfig:false` . + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. Currently, + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields + * that have been explicitly overridden. To issue this query, call + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes + * `indexConfig.usesAncestorConfig:false` . + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Field]{@link google.firestore.admin.v1.Field}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFieldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFields( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.admin.v1.IField[], + protos.google.firestore.admin.v1.IListFieldsRequest|null, + protos.google.firestore.admin.v1.IListFieldsResponse + ]>; + listFields( + request: protos.google.firestore.admin.v1.IListFieldsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, + protos.google.firestore.admin.v1.IField>): void; + listFields( + request: protos.google.firestore.admin.v1.IListFieldsRequest, + callback: PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, + protos.google.firestore.admin.v1.IField>): void; + listFields( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, + protos.google.firestore.admin.v1.IField>, + callback?: PaginationCallback< + protos.google.firestore.admin.v1.IListFieldsRequest, + protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, + protos.google.firestore.admin.v1.IField>): + Promise<[ + protos.google.firestore.admin.v1.IField[], + protos.google.firestore.admin.v1.IListFieldsRequest|null, + protos.google.firestore.admin.v1.IListFieldsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listFields(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. Currently, + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields + * that have been explicitly overridden. To issue this query, call + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes + * `indexConfig.usesAncestorConfig:false` . + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFieldsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listFieldsStream( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listFields']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFields.createStream( + this.innerApiCalls.listFields as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFields`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + * @param {string} request.filter + * The filter to apply to list results. Currently, + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields + * that have been explicitly overridden. To issue this query, call + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes + * `indexConfig.usesAncestorConfig:false` . + * @param {number} request.pageSize + * The number of results to return. + * @param {string} request.pageToken + * A page token, returned from a previous call to + * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next + * page of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Field]{@link google.firestore.admin.v1.Field}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.list_fields.js + * region_tag:firestore_v1_generated_FirestoreAdmin_ListFields_async + */ + listFieldsAsync( + request?: protos.google.firestore.admin.v1.IListFieldsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listFields']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFields.asyncIterate( + this.innerApiCalls['listFields'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified collectionGroup resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @returns {string} Resource name string. + */ + collectionGroupPath(project:string,database:string,collection:string) { + return this.pathTemplates.collectionGroupPathTemplate.render({ + project: project, + database: database, + collection: collection, + }); + } + + /** + * Parse the project from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCollectionGroupName(collectionGroupName: string) { + return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).project; + } + + /** + * Parse the database from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromCollectionGroupName(collectionGroupName: string) { + return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).database; + } + + /** + * Parse the collection from CollectionGroup resource. + * + * @param {string} collectionGroupName + * A fully-qualified path representing CollectionGroup resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromCollectionGroupName(collectionGroupName: string) { + return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).collection; + } + + /** + * Return a fully-qualified database resource name string. + * + * @param {string} project + * @param {string} database + * @returns {string} Resource name string. + */ + databasePath(project:string,database:string) { + return this.pathTemplates.databasePathTemplate.render({ + project: project, + database: database, + }); + } + + /** + * Parse the project from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).project; + } + + /** + * Parse the database from Database resource. + * + * @param {string} databaseName + * A fully-qualified path representing Database resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromDatabaseName(databaseName: string) { + return this.pathTemplates.databasePathTemplate.match(databaseName).database; + } + + /** + * Return a fully-qualified field resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} field + * @returns {string} Resource name string. + */ + fieldPath(project:string,database:string,collection:string,field:string) { + return this.pathTemplates.fieldPathTemplate.render({ + project: project, + database: database, + collection: collection, + field: field, + }); + } + + /** + * Parse the project from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the project. + */ + matchProjectFromFieldName(fieldName: string) { + return this.pathTemplates.fieldPathTemplate.match(fieldName).project; + } + + /** + * Parse the database from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromFieldName(fieldName: string) { + return this.pathTemplates.fieldPathTemplate.match(fieldName).database; + } + + /** + * Parse the collection from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromFieldName(fieldName: string) { + return this.pathTemplates.fieldPathTemplate.match(fieldName).collection; + } + + /** + * Parse the field from Field resource. + * + * @param {string} fieldName + * A fully-qualified path representing Field resource. + * @returns {string} A string representing the field. + */ + matchFieldFromFieldName(fieldName: string) { + return this.pathTemplates.fieldPathTemplate.match(fieldName).field; + } + + /** + * Return a fully-qualified index resource name string. + * + * @param {string} project + * @param {string} database + * @param {string} collection + * @param {string} index + * @returns {string} Resource name string. + */ + indexPath(project:string,database:string,collection:string,index:string) { + return this.pathTemplates.indexPathTemplate.render({ + project: project, + database: database, + collection: collection, + index: index, + }); + } + + /** + * Parse the project from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the project. + */ + matchProjectFromIndexName(indexName: string) { + return this.pathTemplates.indexPathTemplate.match(indexName).project; + } + + /** + * Parse the database from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the database. + */ + matchDatabaseFromIndexName(indexName: string) { + return this.pathTemplates.indexPathTemplate.match(indexName).database; + } + + /** + * Parse the collection from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the collection. + */ + matchCollectionFromIndexName(indexName: string) { + return this.pathTemplates.indexPathTemplate.match(indexName).collection; + } + + /** + * Parse the index from Index resource. + * + * @param {string} indexName + * A fully-qualified path representing Index resource. + * @returns {string} A string representing the index. + */ + matchIndexFromIndexName(indexName: string) { + return this.pathTemplates.indexPathTemplate.match(indexName).index; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.firestoreAdminStub && !this._terminated) { + return this.firestoreAdminStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json new file mode 100644 index 000000000..f2b58181b --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json @@ -0,0 +1,88 @@ +{ + "interfaces": { + "google.firestore.admin.v1.FirestoreAdmin": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "deadline_exceeded_internal_unavailable": [ + "DEADLINE_EXCEEDED", + "INTERNAL", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateIndex": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListIndexes": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" + }, + "GetIndex": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" + }, + "DeleteIndex": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" + }, + "GetField": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" + }, + "UpdateField": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListFields": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_internal_unavailable", + "retry_params_name": "default" + }, + "ExportDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ImportDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDatabase": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListDatabases": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateDatabase": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json b/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json new file mode 100644 index 000000000..11c6963e5 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/firestore/admin/v1/database.proto", + "../../protos/google/firestore/admin/v1/field.proto", + "../../protos/google/firestore/admin/v1/firestore_admin.proto", + "../../protos/google/firestore/admin/v1/index.proto", + "../../protos/google/firestore/admin/v1/location.proto", + "../../protos/google/firestore/admin/v1/operation.proto" +] diff --git a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..dd1e77d2a --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json @@ -0,0 +1,151 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.firestore.admin.v1", + "libraryPackage": "@google-cloud/firestore-admin", + "services": { + "FirestoreAdmin": { + "clients": { + "grpc": { + "libraryClient": "FirestoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "GetField": { + "methods": [ + "getField" + ] + }, + "GetDatabase": { + "methods": [ + "getDatabase" + ] + }, + "ListDatabases": { + "methods": [ + "listDatabases" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "UpdateField": { + "methods": [ + "updateField" + ] + }, + "ExportDocuments": { + "methods": [ + "exportDocuments" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "UpdateDatabase": { + "methods": [ + "updateDatabase" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + }, + "ListFields": { + "methods": [ + "listFields", + "listFieldsStream", + "listFieldsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirestoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "GetField": { + "methods": [ + "getField" + ] + }, + "GetDatabase": { + "methods": [ + "getDatabase" + ] + }, + "ListDatabases": { + "methods": [ + "listDatabases" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "UpdateField": { + "methods": [ + "updateField" + ] + }, + "ExportDocuments": { + "methods": [ + "exportDocuments" + ] + }, + "ImportDocuments": { + "methods": [ + "importDocuments" + ] + }, + "UpdateDatabase": { + "methods": [ + "updateDatabase" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + }, + "ListFields": { + "methods": [ + "listFields", + "listFieldsStream", + "listFieldsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/index.ts b/owl-bot-staging/admin/v1/src/v1/index.ts new file mode 100644 index 000000000..f837949da --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {FirestoreAdminClient} from './firestore_admin_client'; diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..b5b76cbeb --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const admin = require('@google-cloud/firestore-admin'); + +function main() { + const firestoreAdminClient = new admin.FirestoreAdminClient(); +} + +main(); diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..c663441b8 --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {FirestoreAdminClient} from '@google-cloud/firestore-admin'; + +// check that the client class type name can be used +function doStuffWithFirestoreAdminClient(client: FirestoreAdminClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const firestoreAdminClient = new FirestoreAdminClient(); + doStuffWithFirestoreAdminClient(firestoreAdminClient); +} + +main(); diff --git a/owl-bot-staging/admin/v1/system-test/install.ts b/owl-bot-staging/admin/v1/system-test/install.ts new file mode 100644 index 000000000..8ec452229 --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts b/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts new file mode 100644 index 000000000..201a1f317 --- /dev/null +++ b/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts @@ -0,0 +1,2082 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as firestoreadminModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.FirestoreAdminClient', () => { + it('has servicePath', () => { + const servicePath = firestoreadminModule.v1.FirestoreAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreadminModule.v1.FirestoreAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreadminModule.v1.FirestoreAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreAdminStub, undefined); + await client.initialize(); + assert(client.firestoreAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.firestoreAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getIndex', () => { + it('invokes getIndex without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Index()); + client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); + const [response] = await client.getIndex(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIndex without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Index()); + client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIndex( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IIndex|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIndex with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIndex(request), expectedError); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIndex with closed client', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIndex(request), expectedError); + }); + }); + + describe('deleteIndex', () => { + it('invokes deleteIndex without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); + const [response] = await client.deleteIndex(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteIndex without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteIndex = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteIndex( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteIndex with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteIndex(request), expectedError); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteIndex with closed client', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteIndex(request), expectedError); + }); + }); + + describe('getField', () => { + it('invokes getField without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Field()); + client.innerApiCalls.getField = stubSimpleCall(expectedResponse); + const [response] = await client.getField(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getField as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getField without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Field()); + client.innerApiCalls.getField = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getField( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IField|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getField as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getField with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getField(request), expectedError); + assert((client.innerApiCalls.getField as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getField with closed client', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getField(request), expectedError); + }); + }); + + describe('getDatabase', () => { + it('invokes getDatabase without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Database()); + client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); + const [response] = await client.getDatabase(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDatabase without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Database()); + client.innerApiCalls.getDatabase = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDatabase( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IDatabase|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDatabase with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDatabase(request), expectedError); + assert((client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDatabase with closed client', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDatabase(request), expectedError); + }); + }); + + describe('listDatabases', () => { + it('invokes listDatabases without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesResponse()); + client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); + const [response] = await client.listDatabases(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDatabases without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesResponse()); + client.innerApiCalls.listDatabases = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatabases( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IListDatabasesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDatabases with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabases(request), expectedError); + assert((client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDatabases with closed client', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listDatabases(request), expectedError); + }); + }); + + describe('createIndex', () => { + it('invokes createIndex without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); + const [operation] = await client.createIndex(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createIndex without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createIndex( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createIndex with call error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createIndex(request), expectedError); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createIndex with LRO error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createIndex(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateIndexProgress without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateIndexProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateIndexProgress with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateIndexProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateField', () => { + it('invokes updateField without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = "field.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateField = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateField(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateField as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateField without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = "field.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateField = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateField( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateField as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateField with call error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = "field.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateField(request), expectedError); + assert((client.innerApiCalls.updateField as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateField with LRO error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); + request.field = {}; + request.field.name = ''; + const expectedHeaderRequestParams = "field.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateField(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateField as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateFieldProgress without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFieldProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateFieldProgress with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateFieldProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('exportDocuments', () => { + it('invokes exportDocuments without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.exportDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.exportDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes exportDocuments without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.exportDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes exportDocuments with call error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportDocuments(request), expectedError); + assert((client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes exportDocuments with LRO error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkExportDocumentsProgress without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkExportDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportDocumentsProgress with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkExportDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importDocuments', () => { + it('invokes importDocuments without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.importDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importDocuments without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importDocuments with call error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importDocuments(request), expectedError); + assert((client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importDocuments with LRO error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportDocumentsProgress without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportDocumentsProgress with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateDatabase', () => { + it('invokes updateDatabase without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); + request.database = {}; + request.database.name = ''; + const expectedHeaderRequestParams = "database.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateDatabase = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDatabase without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); + request.database = {}; + request.database.name = ''; + const expectedHeaderRequestParams = "database.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateDatabase = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDatabase( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateDatabase with call error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); + request.database = {}; + request.database.name = ''; + const expectedHeaderRequestParams = "database.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateDatabase(request), expectedError); + assert((client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDatabase with LRO error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); + request.database = {}; + request.database.name = ''; + const expectedHeaderRequestParams = "database.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateDatabase(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateDatabaseProgress without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateDatabaseProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateDatabaseProgress with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkUpdateDatabaseProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listIndexes', () => { + it('invokes listIndexes without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); + const [response] = await client.listIndexes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listIndexes without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listIndexes( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IIndex[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listIndexes with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listIndexes(request), expectedError); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listIndexesStream without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Index[] = []; + stream.on('data', (response: protos.google.firestore.admin.v1.Index) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listIndexesStream with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Index[] = []; + stream.on('data', (response: protos.google.firestore.admin.v1.Index) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + generateSampleMessage(new protos.google.firestore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.admin.v1.IIndex[] = []; + const iterable = client.listIndexesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listIndexesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.admin.v1.IIndex[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listFields', () => { + it('invokes listFields without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.innerApiCalls.listFields = stubSimpleCall(expectedResponse); + const [response] = await client.listFields(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFields as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFields without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.innerApiCalls.listFields = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFields( + request, + (err?: Error|null, result?: protos.google.firestore.admin.v1.IField[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFields as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFields with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFields(request), expectedError); + assert((client.innerApiCalls.listFields as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFieldsStream without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.descriptors.page.listFields.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFieldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Field[] = []; + stream.on('data', (response: protos.google.firestore.admin.v1.Field) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFields, request)); + assert.strictEqual( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listFieldsStream with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listFields.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFieldsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.admin.v1.Field[] = []; + stream.on('data', (response: protos.google.firestore.admin.v1.Field) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFields, request)); + assert.strictEqual( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFields without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + generateSampleMessage(new protos.google.firestore.admin.v1.Field()), + ]; + client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.admin.v1.IField[] = []; + const iterable = client.listFieldsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listFields with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFieldsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.admin.v1.IField[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('collectionGroup', () => { + const fakePath = "/rendered/path/collectionGroup"; + const expectedParameters = { + project: "projectValue", + database: "databaseValue", + collection: "collectionValue", + }; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.collectionGroupPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.collectionGroupPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('collectionGroupPath', () => { + const result = client.collectionGroupPath("projectValue", "databaseValue", "collectionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.collectionGroupPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromCollectionGroupName', () => { + const result = client.matchProjectFromCollectionGroupName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromCollectionGroupName', () => { + const result = client.matchDatabaseFromCollectionGroupName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromCollectionGroupName', () => { + const result = client.matchCollectionFromCollectionGroupName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('database', () => { + const fakePath = "/rendered/path/database"; + const expectedParameters = { + project: "projectValue", + database: "databaseValue", + }; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.databasePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.databasePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('databasePath', () => { + const result = client.databasePath("projectValue", "databaseValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.databasePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDatabaseName', () => { + const result = client.matchProjectFromDatabaseName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromDatabaseName', () => { + const result = client.matchDatabaseFromDatabaseName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.databasePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('field', () => { + const fakePath = "/rendered/path/field"; + const expectedParameters = { + project: "projectValue", + database: "databaseValue", + collection: "collectionValue", + field: "fieldValue", + }; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.fieldPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.fieldPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('fieldPath', () => { + const result = client.fieldPath("projectValue", "databaseValue", "collectionValue", "fieldValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.fieldPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromFieldName', () => { + const result = client.matchProjectFromFieldName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromFieldName', () => { + const result = client.matchDatabaseFromFieldName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromFieldName', () => { + const result = client.matchCollectionFromFieldName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFieldFromFieldName', () => { + const result = client.matchFieldFromFieldName(fakePath); + assert.strictEqual(result, "fieldValue"); + assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('index', () => { + const fakePath = "/rendered/path/index"; + const expectedParameters = { + project: "projectValue", + database: "databaseValue", + collection: "collectionValue", + index: "indexValue", + }; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.indexPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.indexPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('indexPath', () => { + const result = client.indexPath("projectValue", "databaseValue", "collectionValue", "indexValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.indexPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromIndexName', () => { + const result = client.matchProjectFromIndexName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDatabaseFromIndexName', () => { + const result = client.matchDatabaseFromIndexName(fakePath); + assert.strictEqual(result, "databaseValue"); + assert((client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCollectionFromIndexName', () => { + const result = client.matchCollectionFromIndexName(fakePath); + assert.strictEqual(result, "collectionValue"); + assert((client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchIndexFromIndexName', () => { + const result = client.matchIndexFromIndexName(fakePath); + assert.strictEqual(result, "indexValue"); + assert((client.pathTemplates.indexPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/admin/v1/tsconfig.json b/owl-bot-staging/admin/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/admin/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/admin/v1/webpack.config.js b/owl-bot-staging/admin/v1/webpack.config.js new file mode 100644 index 000000000..6eb32a37a --- /dev/null +++ b/owl-bot-staging/admin/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'FirestoreAdmin', + filename: './firestore-admin.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 000000000..b88273f36 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/firestore', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 000000000..481c522b0 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 000000000..494e14786 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 000000000..02057e6ac --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Firestore: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..7719fd82b --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/firestore", + "version": "0.1.0", + "description": "Firestore client for Node.js", + "repository": "googleapis/nodejs-firestore", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google firestore", + "firestore", + "firestore" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/common.proto b/owl-bot-staging/v1/protos/google/firestore/v1/common.proto new file mode 100644 index 000000000..588a9b81b --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/common.proto @@ -0,0 +1,82 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A set of field paths on a document. +// Used to restrict a get or update operation on a document to a subset of its +// fields. +// This is different from standard field masks, as this is always scoped to a +// [Document][google.firestore.v1.Document], and takes in account the dynamic nature of [Value][google.firestore.v1.Value]. +message DocumentMask { + // The list of field paths in the mask. See [Document.fields][google.firestore.v1.Document.fields] for a field + // path syntax reference. + repeated string field_paths = 1; +} + +// A precondition on a document, used for conditional operations. +message Precondition { + // The type of precondition. + oneof condition_type { + // When set to `true`, the target document must exist. + // When set to `false`, the target document must not exist. + bool exists = 1; + + // When set, the target document must exist and have been last updated at + // that time. Timestamp must be microsecond aligned. + google.protobuf.Timestamp update_time = 2; + } +} + +// Options for creating a new transaction. +message TransactionOptions { + // Options for a transaction that can be used to read and write documents. + message ReadWrite { + // An optional transaction to retry. + bytes retry_transaction = 1; + } + + // Options for a transaction that can only be used to read documents. + message ReadOnly { + // The consistency mode for this transaction. If not set, defaults to strong + // consistency. + oneof consistency_selector { + // Reads documents at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 2; + } + } + + // The mode of the transaction. + oneof mode { + // The transaction can only be used for read operations. + ReadOnly read_only = 2; + + // The transaction can be used for both read and write operations. + ReadWrite read_write = 3; + } +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/document.proto b/owl-bot-staging/v1/protos/google/firestore/v1/document.proto new file mode 100644 index 000000000..41283588e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/document.proto @@ -0,0 +1,149 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A Firestore document. +// +// Must not exceed 1 MiB - 4 bytes. +message Document { + // The resource name of the document, for example + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // The document's fields. + // + // The map keys represent field names. + // + // A simple field name contains only characters `a` to `z`, `A` to `Z`, + // `0` to `9`, or `_`, and must not start with `0` to `9`. For example, + // `foo_bar_17`. + // + // Field names matching the regular expression `__.*__` are reserved. Reserved + // field names are forbidden except in certain documented contexts. The map + // keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be + // empty. + // + // Field paths may be used in other contexts to refer to structured fields + // defined here. For `map_value`, the field path is represented by the simple + // or quoted field names of the containing fields, delimited by `.`. For + // example, the structured field + // `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be + // represented by the field path `foo.x&y`. + // + // Within a field path, a quoted field name starts and ends with `` ` `` and + // may contain any character. Some characters, including `` ` ``, must be + // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and + // `` `bak\`tik` `` represents `` bak`tik ``. + map fields = 2; + + // Output only. The time at which the document was created. + // + // This value increases monotonically when a document is deleted then + // recreated. It can also be compared to values from other documents and + // the `read_time` of a query. + google.protobuf.Timestamp create_time = 3; + + // Output only. The time at which the document was last changed. + // + // This value is initially set to the `create_time` then increases + // monotonically with each change to the document. It can also be + // compared to values from other documents and the `read_time` of a query. + google.protobuf.Timestamp update_time = 4; +} + +// A message that can hold any of the supported value types. +message Value { + // Must have a value set. + oneof value_type { + // A null value. + google.protobuf.NullValue null_value = 11; + + // A boolean value. + bool boolean_value = 1; + + // An integer value. + int64 integer_value = 2; + + // A double value. + double double_value = 3; + + // A timestamp value. + // + // Precise only to microseconds. When stored, any additional precision is + // rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // A string value. + // + // The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes of the UTF-8 representation are considered by + // queries. + string string_value = 17; + + // A bytes value. + // + // Must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes are considered by queries. + bytes bytes_value = 18; + + // A reference to a document. For example: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string reference_value = 5; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An array value. + // + // Cannot directly contain another array value, though can contain an + // map which contains another array. + ArrayValue array_value = 9; + + // A map value. + MapValue map_value = 6; + } +} + +// An array value. +message ArrayValue { + // Values in the array. + repeated Value values = 1; +} + +// A map value. +message MapValue { + // The map's fields. + // + // The map keys represent field names. Field names matching the regular + // expression `__.*__` are reserved. Reserved field names are forbidden except + // in certain documented contexts. The map keys, represented as UTF-8, must + // not exceed 1,500 bytes and cannot be empty. + map fields = 1; +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto b/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto new file mode 100644 index 000000000..17c94ecb4 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto @@ -0,0 +1,912 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/firestore/v1/common.proto"; +import "google/firestore/v1/document.proto"; +import "google/firestore/v1/query.proto"; +import "google/firestore/v1/write.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreProto"; +option java_package = "com.google.firestore.v1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore API. + +// The Cloud Firestore service. +// +// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL +// document database that simplifies storing, syncing, and querying data for +// your mobile, web, and IoT apps at global scale. Its client libraries provide +// live synchronization and offline support, while its security features and +// integrations with Firebase and Google Cloud Platform (GCP) accelerate +// building truly serverless apps. +service Firestore { + option (google.api.default_host) = "firestore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Gets a single document. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/documents/*/**}" + }; + } + + // Lists documents. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + additional_bindings { + get: "/v1/{parent=projects/*/databases/*/documents}/{collection_id}" + } + }; + } + + // Updates or inserts a document. + rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { + option (google.api.http) = { + patch: "/v1/{document.name=projects/*/databases/*/documents/*/**}" + body: "document" + }; + option (google.api.method_signature) = "document,update_mask"; + } + + // Deletes a document. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/documents/*/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets multiple documents. + // + // Documents returned by this method are not guaranteed to be returned in the + // same order that they were requested. + rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:batchGet" + body: "*" + }; + } + + // Starts a new transaction. + rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:beginTransaction" + body: "*" + }; + option (google.api.method_signature) = "database"; + } + + // Commits a transaction, while optionally updating documents. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:commit" + body: "*" + }; + option (google.api.method_signature) = "database,writes"; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:rollback" + body: "*" + }; + option (google.api.method_signature) = "database,transaction"; + } + + // Runs a query. + rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:runQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery" + body: "*" + } + }; + } + + // Partitions a query by returning partition cursors that can be used to run + // the query in parallel. The returned partition cursors are split points that + // can be used by RunQuery as starting/end points for the query results. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:partitionQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" + body: "*" + } + }; + } + + // Streams batches of document updates and deletes, in order. + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. + rpc Listen(stream ListenRequest) returns (stream ListenResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:listen" + body: "*" + }; + } + + // Lists all the collection IDs underneath a document. + rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" + body: "*" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Applies a batch of write operations. + // + // The BatchWrite method does not apply the write operations atomically + // and can apply them out of order. Method does not allow more than one write + // per document. Each write succeeds or fails independently. See the + // [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write. + // + // If you require an atomically applied set of writes, use + // [Commit][google.firestore.v1.Firestore.Commit] instead. + rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:batchWrite" + body: "*" + }; + } + + // Creates a new document. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}" + body: "document" + }; + } +} + +// The request for [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument]. +message GetDocumentRequest { + // Required. The resource name of the Document to get. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 2; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads the document in a transaction. + bytes transaction = 3; + + // Reads the version of the document at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 5; + } +} + +// The request for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. +message ListDocumentsRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + // or `messages`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of documents to return. + int32 page_size = 3; + + // The `next_page_token` value returned from a previous List request, if any. + string page_token = 4; + + // The order to sort results by. For example: `priority desc, name`. + string order_by = 6; + + // The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 7; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 8; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 10; + } + + // If the list should show missing documents. A missing document is a + // document that does not exist but has sub-documents. These documents will + // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1.Document.create_time], + // or [Document.update_time][google.firestore.v1.Document.update_time] set. + // + // Requests with `show_missing` may not specify `where` or + // `order_by`. + bool show_missing = 12; +} + +// The response for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. +message ListDocumentsResponse { + // The Documents found. + repeated Document documents = 1; + + // The next page token. + string next_page_token = 2; +} + +// The request for [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument]. +message CreateDocumentRequest { + // Required. The parent resource. For example: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The client-assigned document ID to use for this document. + // + // Optional. If not specified, an ID will be assigned by the service. + string document_id = 3; + + // Required. The document to create. `name` must not be set. + Document document = 4 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 5; +} + +// The request for [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument]. +message UpdateDocumentRequest { + // Required. The updated document. + // Creates the document if it does not already exist. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to update. + // None of the field paths in the mask may contain a reserved name. + // + // If the document exists on the server and has fields not referenced in the + // mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + DocumentMask update_mask = 2; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 3; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// The request for [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument]. +message DeleteDocumentRequest { + // Required. The resource name of the Document to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 2; +} + +// The request for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of the + // given `database`. Duplicate names will be elided. + repeated string documents = 2; + + // The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field will + // not be returned in the response. + DocumentMask mask = 3; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 4; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsResponse { + // A single result. + // This can be empty if the server is just returning a transaction. + oneof result { + // A document that was requested. + Document found = 1; + + // A document name that was requested but does not exist. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string missing = 2; + } + + // The transaction that was started as part of this request. + // Will only be set in the first response, and only if + // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction] was set in the request. + bytes transaction = 3; + + // The time at which the document was read. + // This may be monotically increasing, in this case the previous documents in + // the result stream are guaranteed not to have changed between their + // read_time and this one. + google.protobuf.Timestamp read_time = 4; +} + +// The request for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. +message BeginTransactionRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The options for the transaction. + // Defaults to a read-write transaction. + TransactionOptions options = 2; +} + +// The response for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction that was started. + bytes transaction = 1; +} + +// The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. +message CommitRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Always executed atomically and in order. + repeated Write writes = 2; + + // If set, applies all writes in this transaction, and commits it. + bytes transaction = 3; +} + +// The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. +message CommitResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the commit. + google.protobuf.Timestamp commit_time = 2; +} + +// The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback]. +message RollbackRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The transaction to roll back. + bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. +message RunQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 6; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The response for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. +message RunQueryResponse { + // The transaction that was started as part of this request. + // Can only be set in the first response, and only if + // [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction] was set in the request. + // If set, no other fields will be set in this response. + bytes transaction = 2; + + // A query result, not set when reporting partial progress. + Document document = 1; + + // The time at which the document was read. This may be monotonically + // increasing; in this case, the previous documents in the result stream are + // guaranteed not to have changed between their `read_time` and this one. + // + // If the query returns no results, a response with `read_time` and no + // `document` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; + + // The number of results that have been skipped due to an offset between + // the last response and the current response. + int32 skipped_results = 4; + + // The continuation mode for the query. If present, it indicates the current + // query response stream has finished. This can be set with or without a + // `document` present, but when set, no more results are returned. + oneof continuation_selector { + // If present, Firestore has completely finished the request and no more + // documents will be returned. + bool done = 6; + } +} + +// The request for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents`. + // Document resource names are not supported; only database resource names + // can be specified. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to partition. + oneof query_type { + // A structured query. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. + StructuredQuery structured_query = 2; + } + + // The desired maximum number of partition points. + // The partitions may be returned across multiple pages of results. + // The number must be positive. The actual number of partitions + // returned may be fewer. + // + // For example, this may be set to one fewer than the number of parallel + // queries to be run, or in running a data pipeline job, one fewer than the + // number of workers or compute instances available. + int64 partition_count = 3; + + // The `next_page_token` value returned from a previous call to + // PartitionQuery that may be used to get an additional set of results. + // There are no ordering guarantees between sets of results. Thus, using + // multiple sets of results will require merging the different result sets. + // + // For example, two subsequent calls using a page_token may return: + // + // * cursor B, cursor M, cursor Q + // * cursor A, cursor U, cursor W + // + // To obtain a complete result set ordered with respect to the results of the + // query supplied to PartitionQuery, the results sets should be merged: + // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + string page_token = 4; + + // The maximum number of partitions to return in this call, subject to + // `partition_count`. + // + // For example, if `partition_count` = 10 and `page_size` = 8, the first call + // to PartitionQuery will return up to 8 partitions and a `next_page_token` + // 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 response for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryResponse { + // Partition results. + // Each partition is a split point that can be used by RunQuery as a starting + // or end point for the query results. The RunQuery requests must be made with + // the same query supplied to this PartitionQuery request. The partition + // cursors will be ordered according to same ordering as the results of the + // query supplied to PartitionQuery. + // + // For example, if a PartitionQuery request returns partition cursors A and B, + // running the following three queries will return the entire result set of + // the original query: + // + // * query, end_at A + // * query, start_at A, end_at B + // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned. + repeated Cursor partitions = 1; + + // A page token that may be used to request an additional set of results, up + // to the number specified by `partition_count` in the PartitionQuery request. + // If blank, there are no more results. + string next_page_token = 2; +} + +// The request for [Firestore.Write][google.firestore.v1.Firestore.Write]. +// +// The first request creates a stream, or resumes an existing one from a token. +// +// When creating a new stream, the server replies with a response containing +// only an ID and a token, to use in the next request. +// +// When resuming a stream, the server first streams any responses later than the +// given token, then a response containing only an up-to-date token, to use in +// the next request. +message WriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + // This is only required in the first message. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the write stream to resume. + // This may only be set in the first message. When left empty, a new write + // stream will be created. + string stream_id = 2; + + // The writes to apply. + // + // Always executed atomically and in order. + // This must be empty on the first request. + // This may be empty on the last request. + // This must not be empty on all other requests. + repeated Write writes = 3; + + // A stream token that was previously sent by the server. + // + // The client should set this field to the token from the most recent + // [WriteResponse][google.firestore.v1.WriteResponse] it has received. This acknowledges that the client has + // received responses up to this token. After sending this token, earlier + // tokens may not be used anymore. + // + // The server may close the stream if there are too many unacknowledged + // responses. + // + // Leave this field unset when creating a new stream. To resume a stream at + // a specific point, set this field and the `stream_id` field. + // + // Leave this field unset when creating a new stream. + bytes stream_token = 4; + + // Labels associated with this write request. + map labels = 5; +} + +// The response for [Firestore.Write][google.firestore.v1.Firestore.Write]. +message WriteResponse { + // The ID of the stream. + // Only set on the first message, when a new stream was created. + string stream_id = 1; + + // A token that represents the position of this response in the stream. + // This can be used by a client to resume the stream at this point. + // + // This field is always set. + bytes stream_token = 2; + + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 3; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the write. + google.protobuf.Timestamp commit_time = 4; +} + +// A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen] +message ListenRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The supported target changes. + oneof target_change { + // A target to add to this stream. + Target add_target = 2; + + // The ID of a target to remove from this stream. + int32 remove_target = 3; + } + + // Labels associated with this target change. + map labels = 4; +} + +// The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen]. +message ListenResponse { + // The supported responses. + oneof response_type { + // Targets have changed. + TargetChange target_change = 2; + + // A [Document][google.firestore.v1.Document] has changed. + DocumentChange document_change = 3; + + // A [Document][google.firestore.v1.Document] has been deleted. + DocumentDelete document_delete = 4; + + // A [Document][google.firestore.v1.Document] has been removed from a target (because it is no longer + // relevant to that target). + DocumentRemove document_remove = 6; + + // A filter to apply to the set of documents previously returned for the + // given target. + // + // Returned when documents may have been removed from the given target, but + // the exact documents are unknown. + ExistenceFilter filter = 5; + } +} + +// A specification of a set of documents to listen to. +message Target { + // A target specified by a set of documents names. + message DocumentsTarget { + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of + // the given `database`. Duplicate names will be elided. + repeated string documents = 2; + } + + // A target specified by a query. + message QueryTarget { + // The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + } + + // The type of target to listen to. + oneof target_type { + // A target specified by a query. + QueryTarget query = 2; + + // A target specified by a set of document names. + DocumentsTarget documents = 3; + } + + // When to start listening. + // + // If not specified, all matching Documents are returned before any + // subsequent changes. + oneof resume_type { + // A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target. + // + // Using a resume token with a different target is unsupported and may fail. + bytes resume_token = 4; + + // Start listening after a specific `read_time`. + // + // The client must know the state of matching documents at this time. + google.protobuf.Timestamp read_time = 11; + } + + // The target ID that identifies the target on the stream. Must be a positive + // number and non-zero. + int32 target_id = 5; + + // If the target should be removed once it is current and consistent. + bool once = 6; +} + +// Targets being watched have changed. +message TargetChange { + // The type of change. + enum TargetChangeType { + // No change has occurred. Used only to send an updated `resume_token`. + NO_CHANGE = 0; + + // The targets have been added. + ADD = 1; + + // The targets have been removed. + REMOVE = 2; + + // The targets reflect all changes committed before the targets were added + // to the stream. + // + // This will be sent after or with a `read_time` that is greater than or + // equal to the time at which the targets were added. + // + // Listeners can wait for this change if read-after-write semantics + // are desired. + CURRENT = 3; + + // The targets have been reset, and a new initial state for the targets + // will be returned in subsequent changes. + // + // After the initial state is complete, `CURRENT` will be returned even + // if the target was previously indicated to be `CURRENT`. + RESET = 4; + } + + // The type of change that occurred. + TargetChangeType target_change_type = 1; + + // The target IDs of targets that have changed. + // + // If empty, the change applies to all targets. + // + // The order of the target IDs is not defined. + repeated int32 target_ids = 2; + + // The error that resulted in this change, if applicable. + google.rpc.Status cause = 3; + + // A token that can be used to resume the stream for the given `target_ids`, + // or all targets if `target_ids` is empty. + // + // Not set on every target change. + bytes resume_token = 4; + + // The consistent `read_time` for the given `target_ids` (omitted when the + // target_ids are not at a consistent snapshot). + // + // The stream is guaranteed to send a `read_time` with `target_ids` empty + // whenever the entire stream reaches a new consistent snapshot. ADD, + // CURRENT, and RESET messages are guaranteed to (eventually) result in a + // new consistent snapshot (while NO_CHANGE and REMOVE messages are not). + // + // For a given stream, `read_time` is guaranteed to be monotonically + // increasing. + google.protobuf.Timestamp read_time = 6; +} + +// The request for [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. +message ListCollectionIdsRequest { + // Required. The parent document. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A page token. Must be a value from + // [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + string page_token = 3; +} + +// The response from [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. +message ListCollectionIdsResponse { + // The collection ids. + repeated string collection_ids = 1; + + // A page token that may be used to continue the list. + string next_page_token = 2; +} + +// The request for [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. +message BatchWriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Method does not apply writes atomically and does not guarantee ordering. + // Each write succeeds or fails independently. You cannot write to the same + // document more than once per request. + repeated Write writes = 2; + + // Labels associated with this batch write. + map labels = 3; +} + +// The response from [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. +message BatchWriteResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The status of applying the writes. + // + // This i-th write status corresponds to the i-th write in the + // request. + repeated google.rpc.Status status = 2; +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/query.proto b/owl-bot-staging/v1/protos/google/firestore/v1/query.proto new file mode 100644 index 000000000..58163eb62 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/query.proto @@ -0,0 +1,304 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/firestore/v1/document.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A Firestore query. +message StructuredQuery { + // A selection of a collection, such as `messages as m1`. + message CollectionSelector { + // The collection ID. + // When set, selects only collections with this ID. + string collection_id = 2; + + // When false, selects only collections that are immediate children of + // the `parent` specified in the containing `RunQueryRequest`. + // When true, selects all descendant collections. + bool all_descendants = 3; + } + + // A filter. + message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a document field. + FieldFilter field_filter = 2; + + // A filter that takes exactly one argument. + UnaryFilter unary_filter = 3; + } + } + + // A filter that merges multiple other filters using the given operator. + message CompositeFilter { + // A composite filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // Documents are required to satisfy all of the combined filters. + AND = 1; + } + + // The operator for combining multiple filters. + Operator op = 1; + + // The list of filters to combine. + // + // Requires: + // + // * At least one filter is present. + repeated Filter filters = 2; + } + + // A filter on a specific field. + message FieldFilter { + // A field filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is less than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN = 1; + + // The given `field` is less than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `field` is greater than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN = 3; + + // The given `field` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `field` is equal to the given `value`. + EQUAL = 5; + + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + + // The given `field` is an array that contains the given `value`. + ARRAY_CONTAINS = 7; + + // The given `field` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. + IN = 8; + + // The given `field` is an array that contains any of the values in the + // given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. + ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; + } + + // The field to filter by. + FieldReference field = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare to. + Value value = 3; + } + + // A filter with a single operand. + message UnaryFilter { + // A unary operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is equal to `NaN`. + IS_NAN = 2; + + // The given `field` is equal to `NULL`. + IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; + } + + // The unary operator to apply. + Operator op = 1; + + // The argument to the filter. + oneof operand_type { + // The field to which to apply the operator. + FieldReference field = 2; + } + } + + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + + // A sort direction. + enum Direction { + // Unspecified. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + + // The projection to return. + Projection select = 1; + + // The collections to query. + repeated CollectionSelector from = 2; + + // The filter to apply. + Filter where = 3; + + // The order to apply to the query results. + // + // Firestore guarantees a stable ordering through the following rules: + // + // * Any field required to appear in `order_by`, that is not already + // specified in `order_by`, is appended to the order in field name order + // by default. + // * If an order on `__name__` is not specified, it is appended by default. + // + // Fields are appended with the same sort direction as the last order + // specified, or 'ASCENDING' if no order was specified. For example: + // + // * `SELECT * FROM Foo ORDER BY A` becomes + // `SELECT * FROM Foo ORDER BY A, __name__` + // * `SELECT * FROM Foo ORDER BY A DESC` becomes + // `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` + // * `SELECT * FROM Foo WHERE A > 1` becomes + // `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` + repeated Order order_by = 4; + + // A starting point for the query results. + Cursor start_at = 7; + + // A end point for the query results. + Cursor end_at = 8; + + // The number of results to skip. + // + // Applies before limit, but after all other constraints. Must be >= 0 if + // specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 5; +} + +// A position in a query result set. +message Cursor { + // The values that represent a position, in the order they appear in + // the order by clause of a query. + // + // Can contain fewer values than specified in the order by clause. + repeated Value values = 1; + + // If the position is just before or just after the given values, relative + // to the sort order defined by the query. + bool before = 2; +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/write.proto b/owl-bot-staging/v1/protos/google/firestore/v1/write.proto new file mode 100644 index 000000000..c17e96ad9 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/write.proto @@ -0,0 +1,258 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/firestore/v1/common.proto"; +import "google/firestore/v1/document.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "WriteProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A write on a document. +message Write { + // The operation to execute. + oneof operation { + // A document to write. + Document update = 1; + + // A document name to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string delete = 2; + + // Applies a transformation to a document. + DocumentTransform transform = 6; + } + + // The fields to update in this write. + // + // This field can be set only when the operation is `update`. + // If the mask is not set for an `update` and the document exists, any + // existing data will be overwritten. + // If the mask is set and the document on the server has fields not covered by + // the mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + // The field paths in this mask must not contain a reserved field name. + DocumentMask update_mask = 3; + + // The transforms to perform after update. + // + // This field can be set only when the operation is `update`. If present, this + // write is equivalent to performing `update` and `transform` to the same + // document atomically and in order. + repeated DocumentTransform.FieldTransform update_transforms = 7; + + // An optional precondition on the document. + // + // The write will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// A transformation of a document. +message DocumentTransform { + // A transformation of a field of the document. + message FieldTransform { + // A value that is calculated by the server. + enum ServerValue { + // Unspecified. This value must not be used. + SERVER_VALUE_UNSPECIFIED = 0; + + // The time at which the server processed the request, with millisecond + // precision. If used on multiple fields (same or different documents) in + // a transaction, all the fields will get the same server timestamp. + REQUEST_TIME = 1; + } + + // The path of the field. See [Document.fields][google.firestore.v1.Document.fields] for the field path syntax + // reference. + string field_path = 1; + + // The transformation to apply on the field. + oneof transform_type { + // Sets the field to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the field's current value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If either of the given value or the current field value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follow IEEE 754 semantics. + // If there is positive/negative integer overflow, the field is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the field to the maximum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If a maximum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and + // zero input value is always the stored value. + // The maximum of any numeric value x and NaN is NaN. + Value maximum = 4; + + // Sets the field to the minimum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the input value. + // If a minimum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the smaller operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and + // zero input value is always the stored value. + // The minimum of any numeric value x and NaN is NaN. + Value minimum = 5; + + // Append the given elements in order if they are not already present in + // the current field value. + // If the field is not an array, or if the field does not yet exist, it is + // first set to the empty array. + // + // Equivalent numbers of different types (e.g. 3L and 3.0) are + // considered equal when checking if a value is missing. + // NaN is equal to NaN, and Null is equal to Null. + // If the input contains multiple equivalent values, only the first will + // be considered. + // + // The corresponding transform_result will be the null value. + ArrayValue append_missing_elements = 6; + + // Remove all of the given elements from the array in the field. + // If the field is not an array, or if the field does not yet exist, it is + // set to the empty array. + // + // Equivalent numbers of the different types (e.g. 3L and 3.0) are + // considered equal when deciding whether an element should be removed. + // NaN is equal to NaN, and Null is equal to Null. + // This will remove all equivalent values if there are duplicates. + // + // The corresponding transform_result will be the null value. + ArrayValue remove_all_from_array = 7; + } + } + + // The name of the document to transform. + string document = 1; + + // The list of transformations to apply to the fields of the document, in + // order. + // This must not be empty. + repeated FieldTransform field_transforms = 2; +} + +// The result of applying a write. +message WriteResult { + // The last update time of the document after applying the write. Not set + // after a `delete`. + // + // If the write did not actually change the document, this will be the + // previous update_time. + google.protobuf.Timestamp update_time = 1; + + // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform], in the + // same order. + repeated Value transform_results = 2; +} + +// A [Document][google.firestore.v1.Document] has changed. +// +// May be the result of multiple [writes][google.firestore.v1.Write], including deletes, that +// ultimately resulted in a new value for the [Document][google.firestore.v1.Document]. +// +// Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be returned for the same logical +// change, if multiple targets are affected. +message DocumentChange { + // The new state of the [Document][google.firestore.v1.Document]. + // + // If `mask` is set, contains only fields that were updated or added. + Document document = 1; + + // A set of target IDs of targets that match this document. + repeated int32 target_ids = 5; + + // A set of target IDs for targets that no longer match this document. + repeated int32 removed_target_ids = 6; +} + +// A [Document][google.firestore.v1.Document] has been deleted. +// +// May be the result of multiple [writes][google.firestore.v1.Write], including updates, the +// last of which deleted the [Document][google.firestore.v1.Document]. +// +// Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be returned for the same logical +// delete, if multiple targets are affected. +message DocumentDelete { + // The resource name of the [Document][google.firestore.v1.Document] that was deleted. + string document = 1; + + // A set of target IDs for targets that previously matched this entity. + repeated int32 removed_target_ids = 6; + + // The read timestamp at which the delete was observed. + // + // Greater or equal to the `commit_time` of the delete. + google.protobuf.Timestamp read_time = 4; +} + +// A [Document][google.firestore.v1.Document] has been removed from the view of the targets. +// +// Sent if the document is no longer relevant to a target and is out of view. +// Can be sent instead of a DocumentDelete or a DocumentChange if the server +// can not send the new value of the document. +// +// Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be returned for the same logical +// write or delete, if multiple targets are affected. +message DocumentRemove { + // The resource name of the [Document][google.firestore.v1.Document] that has gone out of view. + string document = 1; + + // A set of target IDs for targets that previously matched this document. + repeated int32 removed_target_ids = 2; + + // The read timestamp at which the remove was observed. + // + // Greater or equal to the `commit_time` of the change/delete/remove. + google.protobuf.Timestamp read_time = 4; +} + +// A digest of all the documents that match a given target. +message ExistenceFilter { + // The target ID to which this filter applies. + int32 target_id = 1; + + // The total count of documents that match [target_id][google.firestore.v1.ExistenceFilter.target_id]. + // + // If different from the count of documents in the client that match, the + // client must manually determine which documents no longer match the target. + int32 count = 2; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js new file mode 100644 index 000000000..68adcc61c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js @@ -0,0 +1,90 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_BatchGetDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + */ + // const documents = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If a document has a field that is not present in this mask, that field will + * not be returned in the response. + */ + // const mask = {} + /** + * Reads documents in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBatchGetDocuments() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.batchGetDocuments(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callBatchGetDocuments(); + // [END firestore_v1_generated_Firestore_BatchGetDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js new file mode 100644 index 000000000..728b5c4dd --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js @@ -0,0 +1,70 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_BatchWrite_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The writes to apply. + * Method does not apply writes atomically and does not guarantee ordering. + * Each write succeeds or fails independently. You cannot write to the same + * document more than once per request. + */ + // const writes = 1234 + /** + * Labels associated with this batch write. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBatchWrite() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.batchWrite(request); + console.log(response); + } + + callBatchWrite(); + // [END firestore_v1_generated_Firestore_BatchWrite_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js b/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js new file mode 100644 index 000000000..6a6db3aa6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_BeginTransaction_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The options for the transaction. + * Defaults to a read-write transaction. + */ + // const options = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBeginTransaction() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.beginTransaction(request); + console.log(response); + } + + callBeginTransaction(); + // [END firestore_v1_generated_Firestore_BeginTransaction_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js b/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js new file mode 100644 index 000000000..b249f2ddd --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js @@ -0,0 +1,68 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_Commit_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The writes to apply. + * Always executed atomically and in order. + */ + // const writes = 1234 + /** + * If set, applies all writes in this transaction, and commits it. + */ + // const transaction = 'Buffer.from('string')' + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callCommit() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.commit(request); + console.log(response); + } + + callCommit(); + // [END firestore_v1_generated_Firestore_Commit_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js new file mode 100644 index 000000000..dc2db3111 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js @@ -0,0 +1,81 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, collectionId, document) { + // [START firestore_v1_generated_Firestore_CreateDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + */ + // const parent = 'abc123' + /** + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + */ + // const collectionId = 'abc123' + /** + * The client-assigned document ID to use for this document. + * Optional. If not specified, an ID will be assigned by the service. + */ + // const documentId = 'abc123' + /** + * Required. The document to create. `name` must not be set. + */ + // const document = {} + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callCreateDocument() { + // Construct request + const request = { + parent, + collectionId, + document, + }; + + // Run request + const response = await firestoreClient.createDocument(request); + console.log(response); + } + + callCreateDocument(); + // [END firestore_v1_generated_Firestore_CreateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js new file mode 100644 index 000000000..0c2404f89 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_Firestore_DeleteDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + */ + // const name = 'abc123' + /** + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + */ + // const currentDocument = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callDeleteDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await firestoreClient.deleteDocument(request); + console.log(response); + } + + callDeleteDocument(); + // [END firestore_v1_generated_Firestore_DeleteDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js new file mode 100644 index 000000000..83510ea5b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js @@ -0,0 +1,74 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1_generated_Firestore_GetDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + */ + // const name = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * Reads the document in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Reads the version of the document at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callGetDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await firestoreClient.getDocument(request); + console.log(response); + } + + callGetDocument(); + // [END firestore_v1_generated_Firestore_GetDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js b/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js new file mode 100644 index 000000000..2e73185e0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js @@ -0,0 +1,72 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_Firestore_ListCollectionIds_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A page token. Must be a value from + * ListCollectionIdsResponse google.firestore.v1.ListCollectionIdsResponse. + */ + // const pageToken = 'abc123' + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListCollectionIds() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await firestoreClient.listCollectionIdsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCollectionIds(); + // [END firestore_v1_generated_Firestore_ListCollectionIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js b/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js new file mode 100644 index 000000000..0f654ff55 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js @@ -0,0 +1,107 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, collectionId) { + // [START firestore_v1_generated_Firestore_ListDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + */ + // const collectionId = 'abc123' + /** + * The maximum number of documents to return. + */ + // const pageSize = 1234 + /** + * The `next_page_token` value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * The order to sort results by. For example: `priority desc, name`. + */ + // const orderBy = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * Reads documents in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + /** + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, Document.create_time google.firestore.v1.Document.create_time, + * or Document.update_time google.firestore.v1.Document.update_time set. + * Requests with `show_missing` may not specify `where` or + * `order_by`. + */ + // const showMissing = true + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListDocuments() { + // Construct request + const request = { + parent, + collectionId, + }; + + // Run request + const iterable = await firestoreClient.listDocumentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDocuments(); + // [END firestore_v1_generated_Firestore_ListDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js b/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js new file mode 100644 index 000000000..65b65ef4a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js @@ -0,0 +1,75 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_Listen_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * A target to add to this stream. + */ + // const addTarget = {} + /** + * The ID of a target to remove from this stream. + */ + // const removeTarget = 1234 + /** + * Labels associated with this target change. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListen() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.listen(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callListen(); + // [END firestore_v1_generated_Firestore_Listen_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js new file mode 100644 index 000000000..b5c0187a7 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js @@ -0,0 +1,102 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_Firestore_PartitionQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + */ + // const parent = 'abc123' + /** + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + */ + // const structuredQuery = {} + /** + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + */ + // const partitionCount = 1234 + /** + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * For example, two subsequent calls using a page_token may return: + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + */ + // const pageToken = 'abc123' + /** + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + */ + // const pageSize = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callPartitionQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await firestoreClient.partitionQueryAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callPartitionQuery(); + // [END firestore_v1_generated_Firestore_PartitionQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js b/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js new file mode 100644 index 000000000..3ca8a0eed --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database, transaction) { + // [START firestore_v1_generated_Firestore_Rollback_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * Required. The transaction to roll back. + */ + // const transaction = 'Buffer.from('string')' + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRollback() { + // Construct request + const request = { + database, + transaction, + }; + + // Run request + const response = await firestoreClient.rollback(request); + console.log(response); + } + + callRollback(); + // [END firestore_v1_generated_Firestore_Rollback_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js new file mode 100644 index 000000000..dac2ee27b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js @@ -0,0 +1,86 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1_generated_Firestore_RunQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * A structured query. + */ + // const structuredQuery = {} + /** + * Run the query within an already active transaction. + * The value here is the opaque transaction ID to execute the query in. + */ + // const transaction = 'Buffer.from('string')' + /** + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRunQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const stream = await firestoreClient.runQuery(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callRunQuery(); + // [END firestore_v1_generated_Firestore_RunQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js new file mode 100644 index 000000000..e8c38a660 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js @@ -0,0 +1,79 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(document) { + // [START firestore_v1_generated_Firestore_UpdateDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated document. + * Creates the document if it does not already exist. + */ + // const document = {} + /** + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + */ + // const updateMask = {} + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + */ + // const currentDocument = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callUpdateDocument() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await firestoreClient.updateDocument(request); + console.log(response); + } + + callUpdateDocument(); + // [END firestore_v1_generated_Firestore_UpdateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.write.js b/owl-bot-staging/v1/samples/generated/v1/firestore.write.js new file mode 100644 index 000000000..222755de7 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.write.js @@ -0,0 +1,95 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1_generated_Firestore_Write_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * This is only required in the first message. + */ + // const database = 'abc123' + /** + * The ID of the write stream to resume. + * This may only be set in the first message. When left empty, a new write + * stream will be created. + */ + // const streamId = 'abc123' + /** + * The writes to apply. + * Always executed atomically and in order. + * This must be empty on the first request. + * This may be empty on the last request. + * This must not be empty on all other requests. + */ + // const writes = 1234 + /** + * A stream token that was previously sent by the server. + * The client should set this field to the token from the most recent + * WriteResponse google.firestore.v1.WriteResponse it has received. This acknowledges that the client has + * received responses up to this token. After sending this token, earlier + * tokens may not be used anymore. + * The server may close the stream if there are too many unacknowledged + * responses. + * Leave this field unset when creating a new stream. To resume a stream at + * a specific point, set this field and the `stream_id` field. + * Leave this field unset when creating a new stream. + */ + // const streamToken = 'Buffer.from('string')' + /** + * Labels associated with this write request. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callWrite() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.write(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callWrite(); + // [END firestore_v1_generated_Firestore_Write_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json new file mode 100644 index 000000000..f5b6b402e --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json @@ -0,0 +1,803 @@ +{ + "clientLibrary": { + "name": "nodejs-firestore", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.firestore.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "firestore_v1_generated_Firestore_GetDocument_async", + "title": "Firestore getDocument Sample", + "origin": "API_DEFINITION", + "description": " Gets a single document.", + "canonical": true, + "file": "firestore.get_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocument", + "fullName": "google.firestore.v1.Firestore.GetDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "mask", + "type": ".google.firestore.v1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "GetDocument", + "fullName": "google.firestore.v1.Firestore.GetDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_ListDocuments_async", + "title": "Firestore listDocuments Sample", + "origin": "API_DEFINITION", + "description": " Lists documents.", + "canonical": true, + "file": "firestore.list_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 99, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDocuments", + "fullName": "google.firestore.v1.Firestore.ListDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "collection_id", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "mask", + "type": ".google.firestore.v1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "show_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.firestore.v1.ListDocumentsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "ListDocuments", + "fullName": "google.firestore.v1.Firestore.ListDocuments", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_UpdateDocument_async", + "title": "Firestore updateDocument Sample", + "origin": "API_DEFINITION", + "description": " Updates or inserts a document.", + "canonical": true, + "file": "firestore.update_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocument", + "fullName": "google.firestore.v1.Firestore.UpdateDocument", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.firestore.v1.Document" + }, + { + "name": "update_mask", + "type": ".google.firestore.v1.DocumentMask" + }, + { + "name": "mask", + "type": ".google.firestore.v1.DocumentMask" + }, + { + "name": "current_document", + "type": ".google.firestore.v1.Precondition" + } + ], + "resultType": ".google.firestore.v1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "UpdateDocument", + "fullName": "google.firestore.v1.Firestore.UpdateDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_DeleteDocument_async", + "title": "Firestore deleteDocument Sample", + "origin": "API_DEFINITION", + "description": " Deletes a document.", + "canonical": true, + "file": "firestore.delete_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocument", + "fullName": "google.firestore.v1.Firestore.DeleteDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "current_document", + "type": ".google.firestore.v1.Precondition" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "DeleteDocument", + "fullName": "google.firestore.v1.Firestore.DeleteDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_BatchGetDocuments_async", + "title": "Firestore batchGetDocuments Sample", + "origin": "API_DEFINITION", + "description": " Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.", + "canonical": true, + "file": "firestore.batch_get_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchGetDocuments", + "fullName": "google.firestore.v1.Firestore.BatchGetDocuments", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "documents", + "type": "TYPE_STRING[]" + }, + { + "name": "mask", + "type": ".google.firestore.v1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1.BatchGetDocumentsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "BatchGetDocuments", + "fullName": "google.firestore.v1.Firestore.BatchGetDocuments", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_BeginTransaction_async", + "title": "Firestore beginTransaction Sample", + "origin": "API_DEFINITION", + "description": " Starts a new transaction.", + "canonical": true, + "file": "firestore.begin_transaction.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BeginTransaction", + "fullName": "google.firestore.v1.Firestore.BeginTransaction", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.firestore.v1.TransactionOptions" + } + ], + "resultType": ".google.firestore.v1.BeginTransactionResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "BeginTransaction", + "fullName": "google.firestore.v1.Firestore.BeginTransaction", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_Commit_async", + "title": "Firestore commit Sample", + "origin": "API_DEFINITION", + "description": " Commits a transaction, while optionally updating documents.", + "canonical": true, + "file": "firestore.commit.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Commit", + "fullName": "google.firestore.v1.Firestore.Commit", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.firestore.v1.CommitResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "Commit", + "fullName": "google.firestore.v1.Firestore.Commit", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_Rollback_async", + "title": "Firestore rollback Sample", + "origin": "API_DEFINITION", + "description": " Rolls back a transaction.", + "canonical": true, + "file": "firestore.rollback.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Rollback", + "fullName": "google.firestore.v1.Firestore.Rollback", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "Rollback", + "fullName": "google.firestore.v1.Firestore.Rollback", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_RunQuery_async", + "title": "Firestore runQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs a query.", + "canonical": true, + "file": "firestore.run_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunQuery", + "fullName": "google.firestore.v1.Firestore.RunQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_query", + "type": ".google.firestore.v1.StructuredQuery" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1.RunQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "RunQuery", + "fullName": "google.firestore.v1.Firestore.RunQuery", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_PartitionQuery_async", + "title": "Firestore partitionQuery Sample", + "origin": "API_DEFINITION", + "description": " Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.", + "canonical": true, + "file": "firestore.partition_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 94, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PartitionQuery", + "fullName": "google.firestore.v1.Firestore.PartitionQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_query", + "type": ".google.firestore.v1.StructuredQuery" + }, + { + "name": "partition_count", + "type": "TYPE_INT64" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.firestore.v1.PartitionQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "PartitionQuery", + "fullName": "google.firestore.v1.Firestore.PartitionQuery", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_Write_async", + "title": "Firestore write Sample", + "origin": "API_DEFINITION", + "description": " Streams batches of document updates and deletes, in order.", + "canonical": true, + "file": "firestore.write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Write", + "fullName": "google.firestore.v1.Firestore.Write", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "stream_id", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "stream_token", + "type": "TYPE_BYTES" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1.WriteResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "Write", + "fullName": "google.firestore.v1.Firestore.Write", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_Listen_async", + "title": "Firestore listen Sample", + "origin": "API_DEFINITION", + "description": " Listens to changes.", + "canonical": true, + "file": "firestore.listen.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Listen", + "fullName": "google.firestore.v1.Firestore.Listen", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "add_target", + "type": ".google.firestore.v1.Target" + }, + { + "name": "remove_target", + "type": "TYPE_INT32" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1.ListenResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "Listen", + "fullName": "google.firestore.v1.Firestore.Listen", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_ListCollectionIds_async", + "title": "Firestore listCollectionIds Sample", + "origin": "API_DEFINITION", + "description": " Lists all the collection IDs underneath a document.", + "canonical": true, + "file": "firestore.list_collection_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCollectionIds", + "fullName": "google.firestore.v1.Firestore.ListCollectionIds", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.v1.ListCollectionIdsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "ListCollectionIds", + "fullName": "google.firestore.v1.Firestore.ListCollectionIds", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_BatchWrite_async", + "title": "Firestore batchWrite Sample", + "origin": "API_DEFINITION", + "description": " Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write. If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead.", + "canonical": true, + "file": "firestore.batch_write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchWrite", + "fullName": "google.firestore.v1.Firestore.BatchWrite", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1.BatchWriteResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "BatchWrite", + "fullName": "google.firestore.v1.Firestore.BatchWrite", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1_generated_Firestore_CreateDocument_async", + "title": "Firestore createDocument Sample", + "origin": "API_DEFINITION", + "description": " Creates a new document.", + "canonical": true, + "file": "firestore.create_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocument", + "fullName": "google.firestore.v1.Firestore.CreateDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "collection_id", + "type": "TYPE_STRING" + }, + { + "name": "document_id", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.firestore.v1.Document" + }, + { + "name": "mask", + "type": ".google.firestore.v1.DocumentMask" + } + ], + "resultType": ".google.firestore.v1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "CreateDocument", + "fullName": "google.firestore.v1.Firestore.CreateDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1.Firestore" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 000000000..fded33a5a --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const FirestoreClient = v1.FirestoreClient; +type FirestoreClient = v1.FirestoreClient; +export {v1, FirestoreClient}; +export default {v1, FirestoreClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/firestore_client.ts b/owl-bot-staging/v1/src/v1/firestore_client.ts new file mode 100644 index 000000000..2c93c6d5c --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client.ts @@ -0,0 +1,1857 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, GoogleError} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import { PassThrough } from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/firestore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './firestore_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Cloud Firestore service. + * + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. + * @class + * @memberof v1 + */ +export class FirestoreClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + firestoreStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FirestoreClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDocuments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'), + partitionQuery: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'), + listCollectionIds: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds') + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.firestore.v1.Firestore', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreStub) { + return this.firestoreStub; + } + + // Put together the "service stub" for + // google.firestore.v1.Firestore. + this.firestoreStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.firestore.v1.Firestore') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.firestore.v1.Firestore, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreStubMethods = + ['getDocument', 'listDocuments', 'updateDocument', 'deleteDocument', 'batchGetDocuments', 'beginTransaction', 'commit', 'rollback', 'runQuery', 'partitionQuery', 'write', 'listen', 'listCollectionIds', 'batchWrite', 'createDocument']; + for (const methodName of firestoreStubMethods) { + const callPromise = this.firestoreStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit('error', new GoogleError('The client has already been closed.')); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.firestoreStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads the document in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads the version of the document at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.get_document.js + * region_tag:firestore_v1_generated_Firestore_GetDocument_async + */ + getDocument( + request?: protos.google.firestore.v1.IGetDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|undefined, {}|undefined + ]>; + getDocument( + request: protos.google.firestore.v1.IGetDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request: protos.google.firestore.v1.IGetDocumentRequest, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request?: protos.google.firestore.v1.IGetDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IGetDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getDocument(request, options, callback); + } +/** + * Updates or inserts a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.v1.Document} request.document + * Required. The updated document. + * Creates the document if it does not already exist. + * @param {google.firestore.v1.DocumentMask} request.updateMask + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {google.firestore.v1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.update_document.js + * region_tag:firestore_v1_generated_Firestore_UpdateDocument_async + */ + updateDocument( + request?: protos.google.firestore.v1.IUpdateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>; + updateDocument( + request: protos.google.firestore.v1.IUpdateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request: protos.google.firestore.v1.IUpdateDocumentRequest, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request?: protos.google.firestore.v1.IUpdateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'document.name': request.document!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateDocument(request, options, callback); + } +/** + * Deletes a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.delete_document.js + * region_tag:firestore_v1_generated_Firestore_DeleteDocument_async + */ + deleteDocument( + request?: protos.google.firestore.v1.IDeleteDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>; + deleteDocument( + request: protos.google.firestore.v1.IDeleteDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request: protos.google.firestore.v1.IDeleteDocumentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request?: protos.google.firestore.v1.IDeleteDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteDocument(request, options, callback); + } +/** + * Starts a new transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {google.firestore.v1.TransactionOptions} request.options + * The options for the transaction. + * Defaults to a read-write transaction. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.begin_transaction.js + * region_tag:firestore_v1_generated_Firestore_BeginTransaction_async + */ + beginTransaction( + request?: protos.google.firestore.v1.IBeginTransactionRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|undefined, {}|undefined + ]>; + beginTransaction( + request: protos.google.firestore.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request: protos.google.firestore.v1.IBeginTransactionRequest, + callback: Callback< + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request?: protos.google.firestore.v1.IBeginTransactionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.IBeginTransactionResponse, + protos.google.firestore.v1.IBeginTransactionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.beginTransaction(request, options, callback); + } +/** + * Commits a transaction, while optionally updating documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {number[]} request.writes + * The writes to apply. + * + * Always executed atomically and in order. + * @param {Buffer} request.transaction + * If set, applies all writes in this transaction, and commits it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1.CommitResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.commit.js + * region_tag:firestore_v1_generated_Firestore_Commit_async + */ + commit( + request?: protos.google.firestore.v1.ICommitRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|undefined, {}|undefined + ]>; + commit( + request: protos.google.firestore.v1.ICommitRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request: protos.google.firestore.v1.ICommitRequest, + callback: Callback< + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request?: protos.google.firestore.v1.ICommitRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.ICommitResponse, + protos.google.firestore.v1.ICommitRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.commit(request, options, callback); + } +/** + * Rolls back a transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {Buffer} request.transaction + * Required. The transaction to roll back. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.rollback.js + * region_tag:firestore_v1_generated_Firestore_Rollback_async + */ + rollback( + request?: protos.google.firestore.v1.IRollbackRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|undefined, {}|undefined + ]>; + rollback( + request: protos.google.firestore.v1.IRollbackRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request: protos.google.firestore.v1.IRollbackRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request?: protos.google.firestore.v1.IRollbackRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1.IRollbackRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.rollback(request, options, callback); + } +/** + * Applies a batch of write operations. + * + * The BatchWrite method does not apply the write operations atomically + * and can apply them out of order. Method does not allow more than one write + * per document. Each write succeeds or fails independently. See the + * {@link google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link google.firestore.v1.Firestore.Commit|Commit} instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {number[]} request.writes + * The writes to apply. + * + * Method does not apply writes atomically and does not guarantee ordering. + * Each write succeeds or fails independently. You cannot write to the same + * document more than once per request. + * @param {number[]} request.labels + * Labels associated with this batch write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchWriteResponse]{@link google.firestore.v1.BatchWriteResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.batch_write.js + * region_tag:firestore_v1_generated_Firestore_BatchWrite_async + */ + batchWrite( + request?: protos.google.firestore.v1.IBatchWriteRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|undefined, {}|undefined + ]>; + batchWrite( + request: protos.google.firestore.v1.IBatchWriteRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): void; + batchWrite( + request: protos.google.firestore.v1.IBatchWriteRequest, + callback: Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): void; + batchWrite( + request?: protos.google.firestore.v1.IBatchWriteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.IBatchWriteResponse, + protos.google.firestore.v1.IBatchWriteRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.batchWrite(request, options, callback); + } +/** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/firestore.create_document.js + * region_tag:firestore_v1_generated_Firestore_CreateDocument_async + */ + createDocument( + request?: protos.google.firestore.v1.ICreateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>; + createDocument( + request: protos.google.firestore.v1.ICreateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request: protos.google.firestore.v1.ICreateDocumentRequest, + callback: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request?: protos.google.firestore.v1.ICreateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1.IDocument, + protos.google.firestore.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createDocument(request, options, callback); + } + +/** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field will + * not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example include:samples/generated/v1/firestore.batch_get_documents.js + * region_tag:firestore_v1_generated_Firestore_BatchGetDocuments_async + */ + batchGetDocuments( + request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.batchGetDocuments(request, options); + } + +/** + * Runs a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Run the query within an already active transaction. + * + * The value here is the opaque transaction ID to execute the query in. + * @param {google.firestore.v1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example include:samples/generated/v1/firestore.run_query.js + * region_tag:firestore_v1_generated_Firestore_RunQuery_async + */ + runQuery( + request?: protos.google.firestore.v1.IRunQueryRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.runQuery(request, options); + } + +/** + * Streams batches of document updates and deletes, in order. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1/firestore.write.js + * region_tag:firestore_v1_generated_Firestore_Write_async + */ + write( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.write(null, options); + } + +/** + * Listens to changes. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1/firestore.listen.js + * region_tag:firestore_v1_generated_Firestore_Listen_async + */ + listen( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.listen(null, options); + } + + /** + * Lists documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Document]{@link google.firestore.v1.Document}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocuments( + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.IDocument[], + protos.google.firestore.v1.IListDocumentsRequest|null, + protos.google.firestore.v1.IListDocumentsResponse + ]>; + listDocuments( + request: protos.google.firestore.v1.IListDocumentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1.IDocument>): void; + listDocuments( + request: protos.google.firestore.v1.IListDocumentsRequest, + callback: PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1.IDocument>): void; + listDocuments( + request?: protos.google.firestore.v1.IListDocumentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1.IDocument>, + callback?: PaginationCallback< + protos.google.firestore.v1.IListDocumentsRequest, + protos.google.firestore.v1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1.IDocument>): + Promise<[ + protos.google.firestore.v1.IDocument[], + protos.google.firestore.v1.IListDocumentsRequest|null, + protos.google.firestore.v1.IListDocumentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listDocuments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firestore.list_documents.js + * region_tag:firestore_v1_generated_Firestore_ListDocuments_async + */ + listDocumentsAsync( + request?: protos.google.firestore.v1.IListDocumentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.asyncIterate( + this.innerApiCalls['listDocuments'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Partitions a query by returning partition cursors that can be used to run + * the query in parallel. The returned partition cursors are split points that + * can be used by RunQuery as starting/end points for the query results. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Cursor]{@link google.firestore.v1.Cursor}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQuery( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1.ICursor[], + protos.google.firestore.v1.IPartitionQueryRequest|null, + protos.google.firestore.v1.IPartitionQueryResponse + ]>; + partitionQuery( + request: protos.google.firestore.v1.IPartitionQueryRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1.ICursor>): void; + partitionQuery( + request: protos.google.firestore.v1.IPartitionQueryRequest, + callback: PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1.ICursor>): void; + partitionQuery( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1.ICursor>, + callback?: PaginationCallback< + protos.google.firestore.v1.IPartitionQueryRequest, + protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1.ICursor>): + Promise<[ + protos.google.firestore.v1.ICursor[], + protos.google.firestore.v1.IPartitionQueryRequest|null, + protos.google.firestore.v1.IPartitionQueryResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.partitionQuery(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Cursor]{@link google.firestore.v1.Cursor} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQueryStream( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['partitionQuery']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.partitionQuery.createStream( + this.innerApiCalls.partitionQuery as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `partitionQuery`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firestore.partition_query.js + * region_tag:firestore_v1_generated_Firestore_PartitionQuery_async + */ + partitionQueryAsync( + request?: protos.google.firestore.v1.IPartitionQueryRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['partitionQuery']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.partitionQuery.asyncIterate( + this.innerApiCalls['partitionQuery'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Lists all the collection IDs underneath a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIds( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions): + Promise<[ + string[], + protos.google.firestore.v1.IListCollectionIdsRequest|null, + protos.google.firestore.v1.IListCollectionIdsResponse + ]>; + listCollectionIds( + request: protos.google.firestore.v1.IListCollectionIdsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, + string>): void; + listCollectionIds( + request: protos.google.firestore.v1.IListCollectionIdsRequest, + callback: PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, + string>): void; + listCollectionIds( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, + string>, + callback?: PaginationCallback< + protos.google.firestore.v1.IListCollectionIdsRequest, + protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, + string>): + Promise<[ + string[], + protos.google.firestore.v1.IListCollectionIdsRequest|null, + protos.google.firestore.v1.IListCollectionIdsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCollectionIds(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIdsStream( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCollectionIds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectionIds.createStream( + this.innerApiCalls.listCollectionIds as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCollectionIds`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/firestore.list_collection_ids.js + * region_tag:firestore_v1_generated_Firestore_ListCollectionIds_async + */ + listCollectionIdsAsync( + request?: protos.google.firestore.v1.IListCollectionIdsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCollectionIds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectionIds.asyncIterate( + this.innerApiCalls['listCollectionIds'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.firestoreStub && !this._terminated) { + return this.firestoreStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/firestore_client_config.json b/owl-bot-staging/v1/src/v1/firestore_client_config.json new file mode 100644 index 000000000..65c9d8705 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client_config.json @@ -0,0 +1,116 @@ +{ + "interfaces": { + "google.firestore.v1.Firestore": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "deadline_exceeded_resource_exhausted_internal_unavailable": [ + "DEADLINE_EXCEEDED", + "RESOURCE_EXHAUSTED", + "INTERNAL", + "UNAVAILABLE" + ], + "resource_exhausted_unavailable": [ + "RESOURCE_EXHAUSTED", + "UNAVAILABLE" + ], + "resource_exhausted_aborted_unavailable": [ + "RESOURCE_EXHAUSTED", + "ABORTED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetDocument": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "ListDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "UpdateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "resource_exhausted_unavailable", + "retry_params_name": "default" + }, + "DeleteDocument": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "BatchGetDocuments": { + "timeout_millis": 300000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "BeginTransaction": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "Commit": { + "timeout_millis": 60000, + "retry_codes_name": "resource_exhausted_unavailable", + "retry_params_name": "default" + }, + "Rollback": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "RunQuery": { + "timeout_millis": 300000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "PartitionQuery": { + "timeout_millis": 300000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "Write": { + "timeout_millis": 86400000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Listen": { + "timeout_millis": 86400000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "ListCollectionIds": { + "timeout_millis": 60000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", + "retry_params_name": "default" + }, + "BatchWrite": { + "timeout_millis": 60000, + "retry_codes_name": "resource_exhausted_aborted_unavailable", + "retry_params_name": "default" + }, + "CreateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "resource_exhausted_unavailable", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/firestore_proto_list.json b/owl-bot-staging/v1/src/v1/firestore_proto_list.json new file mode 100644 index 000000000..dcd35e64b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/firestore/v1/common.proto", + "../../protos/google/firestore/v1/document.proto", + "../../protos/google/firestore/v1/firestore.proto", + "../../protos/google/firestore/v1/query.proto", + "../../protos/google/firestore/v1/write.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..954b6b4de --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,165 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.firestore.v1", + "libraryPackage": "@google-cloud/firestore", + "services": { + "Firestore": { + "clients": { + "grpc": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "BatchGetDocuments": { + "methods": [ + "batchGetDocuments" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "Write": { + "methods": [ + "write" + ] + }, + "Listen": { + "methods": [ + "listen" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 000000000..80ccfc089 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {FirestoreClient} from './firestore_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..e6b4d6d26 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const firestore = require('@google-cloud/firestore'); + +function main() { + const firestoreClient = new firestore.FirestoreClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..31569a962 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {FirestoreClient} from '@google-cloud/firestore'; + +// check that the client class type name can be used +function doStuffWithFirestoreClient(client: FirestoreClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const firestoreClient = new FirestoreClient(); + doStuffWithFirestoreClient(firestoreClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 000000000..8ec452229 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_firestore_v1.ts b/owl-bot-staging/v1/test/gapic_firestore_v1.ts new file mode 100644 index 000000000..74a17f6e9 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_firestore_v1.ts @@ -0,0 +1,1928 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as firestoreModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubServerStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // write something to the stream to trigger transformStub and send the response back to the client + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + return sinon.stub().returns(mockStream); +} + +function stubBidiStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.FirestoreClient', () => { + it('has servicePath', () => { + const servicePath = firestoreModule.v1.FirestoreClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreModule.v1.FirestoreClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreModule.v1.FirestoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreModule.v1.FirestoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreModule.v1.FirestoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + + it('has close method for the initialized client', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.firestoreStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDocument with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDocument with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocument(request), expectedError); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateDocument with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDocument with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocument(request), expectedError); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteDocument with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDocument with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocument(request), expectedError); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IBeginTransactionResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes beginTransaction with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.beginTransaction(request), expectedError); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + (err?: Error|null, result?: protos.google.firestore.v1.ICommitResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes commit with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.commit(request), expectedError); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rollback with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollback(request), expectedError); + }); + }); + + describe('batchWrite', () => { + it('invokes batchWrite without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchWriteResponse()); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchWrite without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchWriteResponse()); + client.innerApiCalls.batchWrite = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchWrite( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IBatchWriteResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchWrite with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchWrite with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchWrite(request), expectedError); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createDocument with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDocument with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocument(request), expectedError); + }); + }); + + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsResponse()); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(expectedResponse); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes batchGetDocuments with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(undefined, expectedError); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes batchGetDocuments with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.RunQueryResponse()); + client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes runQuery with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubServerStreamingCall(undefined, expectedError); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes runQuery with closed client', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('write', () => { + it('invokes write without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.WriteRequest()); + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.WriteResponse()); + client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.WriteResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.write as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes write with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.WriteRequest()); + const expectedError = new Error('expected'); + client.innerApiCalls.write = stubBidiStreamingCall(undefined, expectedError); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.WriteResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.write as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('listen', () => { + it('invokes listen without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListenRequest()); + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.ListenResponse()); + client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.ListenResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listen as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes listen with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListenRequest()); + const expectedError = new Error('expected'); + client.innerApiCalls.listen = stubBidiStreamingCall(undefined, expectedError); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.ListenResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.listen as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + (err?: Error|null, result?: protos.google.firestore.v1.IDocument[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDocuments with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert.strictEqual( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert.strictEqual( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + generateSampleMessage(new protos.google.firestore.v1.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.v1.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('partitionQuery', () => { + it('invokes partitionQuery without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); + const [response] = await client.partitionQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes partitionQuery without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partitionQuery( + request, + (err?: Error|null, result?: protos.google.firestore.v1.ICursor[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes partitionQuery with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes partitionQueryStream without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); + assert.strictEqual( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes partitionQueryStream with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); + assert.strictEqual( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1.Cursor()), + ]; + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.v1.ICursor[] = []; + const iterable = client.partitionQueryAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.partitionQueryAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1.ICursor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCollectionIds without error using callback', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCollectionIds( + request, + (err?: Error|null, result?: string[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCollectionIds with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCollectionIdsStream without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCollectionIdsStream with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.listCollectionIdsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCollectionIdsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 000000000..1b321882d --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Firestore', + filename: './firestore.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js new file mode 100644 index 000000000..8849345a0 --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: 'firestore', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js new file mode 100644 index 000000000..481c522b0 --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js new file mode 100644 index 000000000..494e14786 --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md new file mode 100644 index 000000000..02057e6ac --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Firestore: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/v1beta1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 000000000..52d715ebe --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "firestore", + "version": "0.1.0", + "description": "Firestore client for Node.js", + "repository": "googleapis/nodejs-firestore", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google firestore", + "firestore", + "firestore" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto new file mode 100644 index 000000000..59c34dd5d --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto @@ -0,0 +1,83 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1beta1; + +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; + +// A set of field paths on a document. +// Used to restrict a get or update operation on a document to a subset of its +// fields. +// This is different from standard field masks, as this is always scoped to a +// [Document][google.firestore.v1beta1.Document], and takes in account the dynamic nature of [Value][google.firestore.v1beta1.Value]. +message DocumentMask { + // The list of field paths in the mask. See [Document.fields][google.firestore.v1beta1.Document.fields] for a field + // path syntax reference. + repeated string field_paths = 1; +} + +// A precondition on a document, used for conditional operations. +message Precondition { + // The type of precondition. + oneof condition_type { + // When set to `true`, the target document must exist. + // When set to `false`, the target document must not exist. + bool exists = 1; + + // When set, the target document must exist and have been last updated at + // that time. + google.protobuf.Timestamp update_time = 2; + } +} + +// Options for creating a new transaction. +message TransactionOptions { + // Options for a transaction that can be used to read and write documents. + message ReadWrite { + // An optional transaction to retry. + bytes retry_transaction = 1; + } + + // Options for a transaction that can only be used to read documents. + message ReadOnly { + // The consistency mode for this transaction. If not set, defaults to strong + // consistency. + oneof consistency_selector { + // Reads documents at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 2; + } + } + + // The mode of the transaction. + oneof mode { + // The transaction can only be used for read operations. + ReadOnly read_only = 2; + + // The transaction can be used for both read and write operations. + ReadWrite read_write = 3; + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto new file mode 100644 index 000000000..7b9d955b9 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto @@ -0,0 +1,150 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1beta1; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; + +// A Firestore document. +// +// Must not exceed 1 MiB - 4 bytes. +message Document { + // The resource name of the document, for example + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // The document's fields. + // + // The map keys represent field names. + // + // A simple field name contains only characters `a` to `z`, `A` to `Z`, + // `0` to `9`, or `_`, and must not start with `0` to `9`. For example, + // `foo_bar_17`. + // + // Field names matching the regular expression `__.*__` are reserved. Reserved + // field names are forbidden except in certain documented contexts. The map + // keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be + // empty. + // + // Field paths may be used in other contexts to refer to structured fields + // defined here. For `map_value`, the field path is represented by the simple + // or quoted field names of the containing fields, delimited by `.`. For + // example, the structured field + // `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be + // represented by the field path `foo.x&y`. + // + // Within a field path, a quoted field name starts and ends with `` ` `` and + // may contain any character. Some characters, including `` ` ``, must be + // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and + // `` `bak\`tik` `` represents `` bak`tik ``. + map fields = 2; + + // Output only. The time at which the document was created. + // + // This value increases monotonically when a document is deleted then + // recreated. It can also be compared to values from other documents and + // the `read_time` of a query. + google.protobuf.Timestamp create_time = 3; + + // Output only. The time at which the document was last changed. + // + // This value is initially set to the `create_time` then increases + // monotonically with each change to the document. It can also be + // compared to values from other documents and the `read_time` of a query. + google.protobuf.Timestamp update_time = 4; +} + +// A message that can hold any of the supported value types. +message Value { + // Must have a value set. + oneof value_type { + // A null value. + google.protobuf.NullValue null_value = 11; + + // A boolean value. + bool boolean_value = 1; + + // An integer value. + int64 integer_value = 2; + + // A double value. + double double_value = 3; + + // A timestamp value. + // + // Precise only to microseconds. When stored, any additional precision is + // rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // A string value. + // + // The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes of the UTF-8 representation are considered by + // queries. + string string_value = 17; + + // A bytes value. + // + // Must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes are considered by queries. + bytes bytes_value = 18; + + // A reference to a document. For example: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string reference_value = 5; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An array value. + // + // Cannot directly contain another array value, though can contain an + // map which contains another array. + ArrayValue array_value = 9; + + // A map value. + MapValue map_value = 6; + } +} + +// An array value. +message ArrayValue { + // Values in the array. + repeated Value values = 1; +} + +// A map value. +message MapValue { + // The map's fields. + // + // The map keys represent field names. Field names matching the regular + // expression `__.*__` are reserved. Reserved field names are forbidden except + // in certain documented contexts. The map keys, represented as UTF-8, must + // not exceed 1,500 bytes and cannot be empty. + map fields = 1; +} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto new file mode 100644 index 000000000..1fd3a58f3 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto @@ -0,0 +1,900 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/firestore/v1beta1/common.proto"; +import "google/firestore/v1beta1/document.proto"; +import "google/firestore/v1beta1/query.proto"; +import "google/firestore/v1beta1/write.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; + +// Specification of the Firestore API. + +// The Cloud Firestore service. +// +// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL +// document database that simplifies storing, syncing, and querying data for +// your mobile, web, and IoT apps at global scale. Its client libraries provide +// live synchronization and offline support, while its security features and +// integrations with Firebase and Google Cloud Platform (GCP) accelerate +// building truly serverless apps. +service Firestore { + option (google.api.default_host) = "firestore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Gets a single document. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + }; + } + + // Lists documents. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + }; + } + + // Updates or inserts a document. + rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { + option (google.api.http) = { + patch: "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}" + body: "document" + }; + option (google.api.method_signature) = "document,update_mask"; + } + + // Deletes a document. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets multiple documents. + // + // Documents returned by this method are not guaranteed to be returned in the + // same order that they were requested. + rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:batchGet" + body: "*" + }; + } + + // Starts a new transaction. + rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction" + body: "*" + }; + option (google.api.method_signature) = "database"; + } + + // Commits a transaction, while optionally updating documents. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:commit" + body: "*" + }; + option (google.api.method_signature) = "database,writes"; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:rollback" + body: "*" + }; + option (google.api.method_signature) = "database,transaction"; + } + + // Runs a query. + rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery" + body: "*" + } + }; + } + + // Partitions a query by returning partition cursors that can be used to run + // the query in parallel. The returned partition cursors are split points that + // can be used by RunQuery as starting/end points for the query results. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" + body: "*" + } + }; + } + + // Streams batches of document updates and deletes, in order. + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. + rpc Listen(stream ListenRequest) returns (stream ListenResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:listen" + body: "*" + }; + } + + // Lists all the collection IDs underneath a document. + rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" + body: "*" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Applies a batch of write operations. + // + // The BatchWrite method does not apply the write operations atomically + // and can apply them out of order. Method does not allow more than one write + // per document. Each write succeeds or fails independently. See the + // [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write. + // + // If you require an atomically applied set of writes, use + // [Commit][google.firestore.v1beta1.Firestore.Commit] instead. + rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite" + body: "*" + }; + } + + // Creates a new document. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}" + body: "document" + }; + } +} + +// The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument]. +message GetDocumentRequest { + // Required. The resource name of the Document to get. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 2; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads the document in a transaction. + bytes transaction = 3; + + // Reads the version of the document at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 5; + } +} + +// The request for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. +message ListDocumentsRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + // or `messages`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of documents to return. + int32 page_size = 3; + + // The `next_page_token` value returned from a previous List request, if any. + string page_token = 4; + + // The order to sort results by. For example: `priority desc, name`. + string order_by = 6; + + // The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 7; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 8; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 10; + } + + // If the list should show missing documents. A missing document is a + // document that does not exist but has sub-documents. These documents will + // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1beta1.Document.create_time], + // or [Document.update_time][google.firestore.v1beta1.Document.update_time] set. + // + // Requests with `show_missing` may not specify `where` or + // `order_by`. + bool show_missing = 12; +} + +// The response for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. +message ListDocumentsResponse { + // The Documents found. + repeated Document documents = 1; + + // The next page token. + string next_page_token = 2; +} + +// The request for [Firestore.CreateDocument][google.firestore.v1beta1.Firestore.CreateDocument]. +message CreateDocumentRequest { + // Required. The parent resource. For example: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The client-assigned document ID to use for this document. + // + // Optional. If not specified, an ID will be assigned by the service. + string document_id = 3; + + // Required. The document to create. `name` must not be set. + Document document = 4 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 5; +} + +// The request for [Firestore.UpdateDocument][google.firestore.v1beta1.Firestore.UpdateDocument]. +message UpdateDocumentRequest { + // Required. The updated document. + // Creates the document if it does not already exist. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to update. + // None of the field paths in the mask may contain a reserved name. + // + // If the document exists on the server and has fields not referenced in the + // mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + DocumentMask update_mask = 2; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 3; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// The request for [Firestore.DeleteDocument][google.firestore.v1beta1.Firestore.DeleteDocument]. +message DeleteDocumentRequest { + // Required. The resource name of the Document to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 2; +} + +// The request for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of the + // given `database`. Duplicate names will be elided. + repeated string documents = 2; + + // The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field will + // not be returned in the response. + DocumentMask mask = 3; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 4; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsResponse { + // A single result. + // This can be empty if the server is just returning a transaction. + oneof result { + // A document that was requested. + Document found = 1; + + // A document name that was requested but does not exist. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string missing = 2; + } + + // The transaction that was started as part of this request. + // Will only be set in the first response, and only if + // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1beta1.BatchGetDocumentsRequest.new_transaction] was set in the request. + bytes transaction = 3; + + // The time at which the document was read. + // This may be monotically increasing, in this case the previous documents in + // the result stream are guaranteed not to have changed between their + // read_time and this one. + google.protobuf.Timestamp read_time = 4; +} + +// The request for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. +message BeginTransactionRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The options for the transaction. + // Defaults to a read-write transaction. + TransactionOptions options = 2; +} + +// The response for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction that was started. + bytes transaction = 1; +} + +// The request for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. +message CommitRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Always executed atomically and in order. + repeated Write writes = 2; + + // If set, applies all writes in this transaction, and commits it. + bytes transaction = 3; +} + +// The response for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. +message CommitResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the commit. + google.protobuf.Timestamp commit_time = 2; +} + +// The request for [Firestore.Rollback][google.firestore.v1beta1.Firestore.Rollback]. +message RollbackRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The transaction to roll back. + bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. +message RunQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 5; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 6; + + // Reads documents as they were at the given time. + // This may not be older than 270 seconds. + google.protobuf.Timestamp read_time = 7; + } +} + +// The response for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. +message RunQueryResponse { + // The transaction that was started as part of this request. + // Can only be set in the first response, and only if + // [RunQueryRequest.new_transaction][google.firestore.v1beta1.RunQueryRequest.new_transaction] was set in the request. + // If set, no other fields will be set in this response. + bytes transaction = 2; + + // A query result. + // Not set when reporting partial progress. + Document document = 1; + + // The time at which the document was read. This may be monotonically + // increasing; in this case, the previous documents in the result stream are + // guaranteed not to have changed between their `read_time` and this one. + // + // If the query returns no results, a response with `read_time` and no + // `document` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; + + // The number of results that have been skipped due to an offset between + // the last response and the current response. + int32 skipped_results = 4; +} + +// The request for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. +message PartitionQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents`. + // Document resource names are not supported; only database resource names + // can be specified. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to partition. + oneof query_type { + // A structured query. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. + StructuredQuery structured_query = 2; + } + + // The desired maximum number of partition points. + // The partitions may be returned across multiple pages of results. + // The number must be positive. The actual number of partitions + // returned may be fewer. + // + // For example, this may be set to one fewer than the number of parallel + // queries to be run, or in running a data pipeline job, one fewer than the + // number of workers or compute instances available. + int64 partition_count = 3; + + // The `next_page_token` value returned from a previous call to + // PartitionQuery that may be used to get an additional set of results. + // There are no ordering guarantees between sets of results. Thus, using + // multiple sets of results will require merging the different result sets. + // + // For example, two subsequent calls using a page_token may return: + // + // * cursor B, cursor M, cursor Q + // * cursor A, cursor U, cursor W + // + // To obtain a complete result set ordered with respect to the results of the + // query supplied to PartitionQuery, the results sets should be merged: + // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + string page_token = 4; + + // The maximum number of partitions to return in this call, subject to + // `partition_count`. + // + // For example, if `partition_count` = 10 and `page_size` = 8, the first call + // to PartitionQuery will return up to 8 partitions and a `next_page_token` + // 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 response for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. +message PartitionQueryResponse { + // Partition results. + // Each partition is a split point that can be used by RunQuery as a starting + // or end point for the query results. The RunQuery requests must be made with + // the same query supplied to this PartitionQuery request. The partition + // cursors will be ordered according to same ordering as the results of the + // query supplied to PartitionQuery. + // + // For example, if a PartitionQuery request returns partition cursors A and B, + // running the following three queries will return the entire result set of + // the original query: + // + // * query, end_at A + // * query, start_at A, end_at B + // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned. + repeated Cursor partitions = 1; + + // A page token that may be used to request an additional set of results, up + // to the number specified by `partition_count` in the PartitionQuery request. + // If blank, there are no more results. + string next_page_token = 2; +} + +// The request for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. +// +// The first request creates a stream, or resumes an existing one from a token. +// +// When creating a new stream, the server replies with a response containing +// only an ID and a token, to use in the next request. +// +// When resuming a stream, the server first streams any responses later than the +// given token, then a response containing only an up-to-date token, to use in +// the next request. +message WriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + // This is only required in the first message. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the write stream to resume. + // This may only be set in the first message. When left empty, a new write + // stream will be created. + string stream_id = 2; + + // The writes to apply. + // + // Always executed atomically and in order. + // This must be empty on the first request. + // This may be empty on the last request. + // This must not be empty on all other requests. + repeated Write writes = 3; + + // A stream token that was previously sent by the server. + // + // The client should set this field to the token from the most recent + // [WriteResponse][google.firestore.v1beta1.WriteResponse] it has received. This acknowledges that the client has + // received responses up to this token. After sending this token, earlier + // tokens may not be used anymore. + // + // The server may close the stream if there are too many unacknowledged + // responses. + // + // Leave this field unset when creating a new stream. To resume a stream at + // a specific point, set this field and the `stream_id` field. + // + // Leave this field unset when creating a new stream. + bytes stream_token = 4; + + // Labels associated with this write request. + map labels = 5; +} + +// The response for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. +message WriteResponse { + // The ID of the stream. + // Only set on the first message, when a new stream was created. + string stream_id = 1; + + // A token that represents the position of this response in the stream. + // This can be used by a client to resume the stream at this point. + // + // This field is always set. + bytes stream_token = 2; + + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 3; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the write. + google.protobuf.Timestamp commit_time = 4; +} + +// A request for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen] +message ListenRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The supported target changes. + oneof target_change { + // A target to add to this stream. + Target add_target = 2; + + // The ID of a target to remove from this stream. + int32 remove_target = 3; + } + + // Labels associated with this target change. + map labels = 4; +} + +// The response for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen]. +message ListenResponse { + // The supported responses. + oneof response_type { + // Targets have changed. + TargetChange target_change = 2; + + // A [Document][google.firestore.v1beta1.Document] has changed. + DocumentChange document_change = 3; + + // A [Document][google.firestore.v1beta1.Document] has been deleted. + DocumentDelete document_delete = 4; + + // A [Document][google.firestore.v1beta1.Document] has been removed from a target (because it is no longer + // relevant to that target). + DocumentRemove document_remove = 6; + + // A filter to apply to the set of documents previously returned for the + // given target. + // + // Returned when documents may have been removed from the given target, but + // the exact documents are unknown. + ExistenceFilter filter = 5; + } +} + +// A specification of a set of documents to listen to. +message Target { + // A target specified by a set of documents names. + message DocumentsTarget { + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of + // the given `database`. Duplicate names will be elided. + repeated string documents = 2; + } + + // A target specified by a query. + message QueryTarget { + // The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + } + + // The type of target to listen to. + oneof target_type { + // A target specified by a query. + QueryTarget query = 2; + + // A target specified by a set of document names. + DocumentsTarget documents = 3; + } + + // When to start listening. + // + // If not specified, all matching Documents are returned before any + // subsequent changes. + oneof resume_type { + // A resume token from a prior [TargetChange][google.firestore.v1beta1.TargetChange] for an identical target. + // + // Using a resume token with a different target is unsupported and may fail. + bytes resume_token = 4; + + // Start listening after a specific `read_time`. + // + // The client must know the state of matching documents at this time. + google.protobuf.Timestamp read_time = 11; + } + + // The target ID that identifies the target on the stream. Must be a positive + // number and non-zero. + int32 target_id = 5; + + // If the target should be removed once it is current and consistent. + bool once = 6; +} + +// Targets being watched have changed. +message TargetChange { + // The type of change. + enum TargetChangeType { + // No change has occurred. Used only to send an updated `resume_token`. + NO_CHANGE = 0; + + // The targets have been added. + ADD = 1; + + // The targets have been removed. + REMOVE = 2; + + // The targets reflect all changes committed before the targets were added + // to the stream. + // + // This will be sent after or with a `read_time` that is greater than or + // equal to the time at which the targets were added. + // + // Listeners can wait for this change if read-after-write semantics + // are desired. + CURRENT = 3; + + // The targets have been reset, and a new initial state for the targets + // will be returned in subsequent changes. + // + // After the initial state is complete, `CURRENT` will be returned even + // if the target was previously indicated to be `CURRENT`. + RESET = 4; + } + + // The type of change that occurred. + TargetChangeType target_change_type = 1; + + // The target IDs of targets that have changed. + // + // If empty, the change applies to all targets. + // + // The order of the target IDs is not defined. + repeated int32 target_ids = 2; + + // The error that resulted in this change, if applicable. + google.rpc.Status cause = 3; + + // A token that can be used to resume the stream for the given `target_ids`, + // or all targets if `target_ids` is empty. + // + // Not set on every target change. + bytes resume_token = 4; + + // The consistent `read_time` for the given `target_ids` (omitted when the + // target_ids are not at a consistent snapshot). + // + // The stream is guaranteed to send a `read_time` with `target_ids` empty + // whenever the entire stream reaches a new consistent snapshot. ADD, + // CURRENT, and RESET messages are guaranteed to (eventually) result in a + // new consistent snapshot (while NO_CHANGE and REMOVE messages are not). + // + // For a given stream, `read_time` is guaranteed to be monotonically + // increasing. + google.protobuf.Timestamp read_time = 6; +} + +// The request for [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. +message ListCollectionIdsRequest { + // Required. The parent document. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A page token. Must be a value from + // [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. + string page_token = 3; +} + +// The response from [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. +message ListCollectionIdsResponse { + // The collection ids. + repeated string collection_ids = 1; + + // A page token that may be used to continue the list. + string next_page_token = 2; +} + +// The request for [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. +message BatchWriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Method does not apply writes atomically and does not guarantee ordering. + // Each write succeeds or fails independently. You cannot write to the same + // document more than once per request. + repeated Write writes = 2; + + // Labels associated with this batch write. + map labels = 3; +} + +// The response from [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. +message BatchWriteResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The status of applying the writes. + // + // This i-th write status corresponds to the i-th write in the + // request. + repeated google.rpc.Status status = 2; +} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto new file mode 100644 index 000000000..0c14777a2 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto @@ -0,0 +1,301 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1beta1; + +import "google/firestore/v1beta1/document.proto"; +import "google/protobuf/wrappers.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; + +// A Firestore query. +message StructuredQuery { + // A selection of a collection, such as `messages as m1`. + message CollectionSelector { + // The collection ID. + // When set, selects only collections with this ID. + string collection_id = 2; + + // When false, selects only collections that are immediate children of + // the `parent` specified in the containing `RunQueryRequest`. + // When true, selects all descendant collections. + bool all_descendants = 3; + } + + // A filter. + message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a document field. + FieldFilter field_filter = 2; + + // A filter that takes exactly one argument. + UnaryFilter unary_filter = 3; + } + } + + // A filter that merges multiple other filters using the given operator. + message CompositeFilter { + // A composite filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The results are required to satisfy each of the combined filters. + AND = 1; + } + + // The operator for combining multiple filters. + Operator op = 1; + + // The list of filters to combine. + // Must contain at least one filter. + repeated Filter filters = 2; + } + + // A filter on a specific field. + message FieldFilter { + // A field filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is less than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN = 1; + + // The given `field` is less than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `field` is greater than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN = 3; + + // The given `field` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `field` is equal to the given `value`. + EQUAL = 5; + + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + + // The given `field` is an array that contains the given `value`. + ARRAY_CONTAINS = 7; + + // The given `field` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. + IN = 8; + + // The given `field` is an array that contains any of the values in the + // given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. + ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; + } + + // The field to filter by. + FieldReference field = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare to. + Value value = 3; + } + + // A filter with a single operand. + message UnaryFilter { + // A unary operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is equal to `NaN`. + IS_NAN = 2; + + // The given `field` is equal to `NULL`. + IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; + } + + // The unary operator to apply. + Operator op = 1; + + // The argument to the filter. + oneof operand_type { + // The field to which to apply the operator. + FieldReference field = 2; + } + } + + // A reference to a field, such as `max(messages.time) as max_time`. + message FieldReference { + string field_path = 2; + } + + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + + // A sort direction. + enum Direction { + // Unspecified. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // The projection to return. + Projection select = 1; + + // The collections to query. + repeated CollectionSelector from = 2; + + // The filter to apply. + Filter where = 3; + + // The order to apply to the query results. + // + // Firestore guarantees a stable ordering through the following rules: + // + // * Any field required to appear in `order_by`, that is not already + // specified in `order_by`, is appended to the order in field name order + // by default. + // * If an order on `__name__` is not specified, it is appended by default. + // + // Fields are appended with the same sort direction as the last order + // specified, or 'ASCENDING' if no order was specified. For example: + // + // * `SELECT * FROM Foo ORDER BY A` becomes + // `SELECT * FROM Foo ORDER BY A, __name__` + // * `SELECT * FROM Foo ORDER BY A DESC` becomes + // `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` + // * `SELECT * FROM Foo WHERE A > 1` becomes + // `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` + repeated Order order_by = 4; + + // A starting point for the query results. + Cursor start_at = 7; + + // A end point for the query results. + Cursor end_at = 8; + + // The number of results to skip. + // + // Applies before limit, but after all other constraints. Must be >= 0 if + // specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 5; +} + +// A position in a query result set. +message Cursor { + // The values that represent a position, in the order they appear in + // the order by clause of a query. + // + // Can contain fewer values than specified in the order by clause. + repeated Value values = 1; + + // If the position is just before or just after the given values, relative + // to the sort order defined by the query. + bool before = 2; +} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto new file mode 100644 index 000000000..1ca3c1911 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto @@ -0,0 +1,259 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.firestore.v1beta1; + +import "google/firestore/v1beta1/common.proto"; +import "google/firestore/v1beta1/document.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; +option java_multiple_files = true; +option java_outer_classname = "WriteProto"; +option java_package = "com.google.firestore.v1beta1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; +option ruby_package = "Google::Cloud::Firestore::V1beta1"; + +// A write on a document. +message Write { + // The operation to execute. + oneof operation { + // A document to write. + Document update = 1; + + // A document name to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string delete = 2; + + // Applies a transformation to a document. + DocumentTransform transform = 6; + } + + // The fields to update in this write. + // + // This field can be set only when the operation is `update`. + // If the mask is not set for an `update` and the document exists, any + // existing data will be overwritten. + // If the mask is set and the document on the server has fields not covered by + // the mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + // The field paths in this mask must not contain a reserved field name. + DocumentMask update_mask = 3; + + // The transforms to perform after update. + // + // This field can be set only when the operation is `update`. If present, this + // write is equivalent to performing `update` and `transform` to the same + // document atomically and in order. + repeated DocumentTransform.FieldTransform update_transforms = 7; + + // An optional precondition on the document. + // + // The write will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// A transformation of a document. +message DocumentTransform { + // A transformation of a field of the document. + message FieldTransform { + // A value that is calculated by the server. + enum ServerValue { + // Unspecified. This value must not be used. + SERVER_VALUE_UNSPECIFIED = 0; + + // The time at which the server processed the request, with millisecond + // precision. If used on multiple fields (same or different documents) in + // a transaction, all the fields will get the same server timestamp. + REQUEST_TIME = 1; + } + + // The path of the field. See [Document.fields][google.firestore.v1beta1.Document.fields] for the field path syntax + // reference. + string field_path = 1; + + // The transformation to apply on the field. + oneof transform_type { + // Sets the field to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the field's current value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If either of the given value or the current field value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follow IEEE 754 semantics. + // If there is positive/negative integer overflow, the field is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the field to the maximum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If a maximum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and + // zero input value is always the stored value. + // The maximum of any numeric value x and NaN is NaN. + Value maximum = 4; + + // Sets the field to the minimum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the input value. + // If a minimum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the smaller operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and + // zero input value is always the stored value. + // The minimum of any numeric value x and NaN is NaN. + Value minimum = 5; + + // Append the given elements in order if they are not already present in + // the current field value. + // If the field is not an array, or if the field does not yet exist, it is + // first set to the empty array. + // + // Equivalent numbers of different types (e.g. 3L and 3.0) are + // considered equal when checking if a value is missing. + // NaN is equal to NaN, and Null is equal to Null. + // If the input contains multiple equivalent values, only the first will + // be considered. + // + // The corresponding transform_result will be the null value. + ArrayValue append_missing_elements = 6; + + // Remove all of the given elements from the array in the field. + // If the field is not an array, or if the field does not yet exist, it is + // set to the empty array. + // + // Equivalent numbers of the different types (e.g. 3L and 3.0) are + // considered equal when deciding whether an element should be removed. + // NaN is equal to NaN, and Null is equal to Null. + // This will remove all equivalent values if there are duplicates. + // + // The corresponding transform_result will be the null value. + ArrayValue remove_all_from_array = 7; + } + } + + // The name of the document to transform. + string document = 1; + + // The list of transformations to apply to the fields of the document, in + // order. + // This must not be empty. + repeated FieldTransform field_transforms = 2; +} + +// The result of applying a write. +message WriteResult { + // The last update time of the document after applying the write. Not set + // after a `delete`. + // + // If the write did not actually change the document, this will be the + // previous update_time. + google.protobuf.Timestamp update_time = 1; + + // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1beta1.DocumentTransform.FieldTransform], in the + // same order. + repeated Value transform_results = 2; +} + +// A [Document][google.firestore.v1beta1.Document] has changed. +// +// May be the result of multiple [writes][google.firestore.v1beta1.Write], including deletes, that +// ultimately resulted in a new value for the [Document][google.firestore.v1beta1.Document]. +// +// Multiple [DocumentChange][google.firestore.v1beta1.DocumentChange] messages may be returned for the same logical +// change, if multiple targets are affected. +message DocumentChange { + // The new state of the [Document][google.firestore.v1beta1.Document]. + // + // If `mask` is set, contains only fields that were updated or added. + Document document = 1; + + // A set of target IDs of targets that match this document. + repeated int32 target_ids = 5; + + // A set of target IDs for targets that no longer match this document. + repeated int32 removed_target_ids = 6; +} + +// A [Document][google.firestore.v1beta1.Document] has been deleted. +// +// May be the result of multiple [writes][google.firestore.v1beta1.Write], including updates, the +// last of which deleted the [Document][google.firestore.v1beta1.Document]. +// +// Multiple [DocumentDelete][google.firestore.v1beta1.DocumentDelete] messages may be returned for the same logical +// delete, if multiple targets are affected. +message DocumentDelete { + // The resource name of the [Document][google.firestore.v1beta1.Document] that was deleted. + string document = 1; + + // A set of target IDs for targets that previously matched this entity. + repeated int32 removed_target_ids = 6; + + // The read timestamp at which the delete was observed. + // + // Greater or equal to the `commit_time` of the delete. + google.protobuf.Timestamp read_time = 4; +} + +// A [Document][google.firestore.v1beta1.Document] has been removed from the view of the targets. +// +// Sent if the document is no longer relevant to a target and is out of view. +// Can be sent instead of a DocumentDelete or a DocumentChange if the server +// can not send the new value of the document. +// +// Multiple [DocumentRemove][google.firestore.v1beta1.DocumentRemove] messages may be returned for the same logical +// write or delete, if multiple targets are affected. +message DocumentRemove { + // The resource name of the [Document][google.firestore.v1beta1.Document] that has gone out of view. + string document = 1; + + // A set of target IDs for targets that previously matched this document. + repeated int32 removed_target_ids = 2; + + // The read timestamp at which the remove was observed. + // + // Greater or equal to the `commit_time` of the change/delete/remove. + google.protobuf.Timestamp read_time = 4; +} + +// A digest of all the documents that match a given target. +message ExistenceFilter { + // The target ID to which this filter applies. + int32 target_id = 1; + + // The total count of documents that match [target_id][google.firestore.v1beta1.ExistenceFilter.target_id]. + // + // If different from the count of documents in the client that match, the + // client must manually determine which documents no longer match the target. + int32 count = 2; +} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js new file mode 100644 index 000000000..f3a49e484 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js @@ -0,0 +1,90 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_BatchGetDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + */ + // const documents = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If a document has a field that is not present in this mask, that field will + * not be returned in the response. + */ + // const mask = {} + /** + * Reads documents in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBatchGetDocuments() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.batchGetDocuments(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callBatchGetDocuments(); + // [END firestore_v1beta1_generated_Firestore_BatchGetDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js new file mode 100644 index 000000000..9dd18a64e --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js @@ -0,0 +1,70 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_BatchWrite_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The writes to apply. + * Method does not apply writes atomically and does not guarantee ordering. + * Each write succeeds or fails independently. You cannot write to the same + * document more than once per request. + */ + // const writes = 1234 + /** + * Labels associated with this batch write. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBatchWrite() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.batchWrite(request); + console.log(response); + } + + callBatchWrite(); + // [END firestore_v1beta1_generated_Firestore_BatchWrite_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js new file mode 100644 index 000000000..eea9a9ccc --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_BeginTransaction_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The options for the transaction. + * Defaults to a read-write transaction. + */ + // const options = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callBeginTransaction() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.beginTransaction(request); + console.log(response); + } + + callBeginTransaction(); + // [END firestore_v1beta1_generated_Firestore_BeginTransaction_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js new file mode 100644 index 000000000..3747286e4 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js @@ -0,0 +1,68 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_Commit_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * The writes to apply. + * Always executed atomically and in order. + */ + // const writes = 1234 + /** + * If set, applies all writes in this transaction, and commits it. + */ + // const transaction = 'Buffer.from('string')' + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callCommit() { + // Construct request + const request = { + database, + }; + + // Run request + const response = await firestoreClient.commit(request); + console.log(response); + } + + callCommit(); + // [END firestore_v1beta1_generated_Firestore_Commit_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js new file mode 100644 index 000000000..ba53875eb --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js @@ -0,0 +1,81 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, collectionId, document) { + // [START firestore_v1beta1_generated_Firestore_CreateDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + */ + // const parent = 'abc123' + /** + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + */ + // const collectionId = 'abc123' + /** + * The client-assigned document ID to use for this document. + * Optional. If not specified, an ID will be assigned by the service. + */ + // const documentId = 'abc123' + /** + * Required. The document to create. `name` must not be set. + */ + // const document = {} + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callCreateDocument() { + // Construct request + const request = { + parent, + collectionId, + document, + }; + + // Run request + const response = await firestoreClient.createDocument(request); + console.log(response); + } + + callCreateDocument(); + // [END firestore_v1beta1_generated_Firestore_CreateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js new file mode 100644 index 000000000..326f3016a --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1beta1_generated_Firestore_DeleteDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + */ + // const name = 'abc123' + /** + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + */ + // const currentDocument = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callDeleteDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await firestoreClient.deleteDocument(request); + console.log(response); + } + + callDeleteDocument(); + // [END firestore_v1beta1_generated_Firestore_DeleteDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js new file mode 100644 index 000000000..8de5f8aad --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js @@ -0,0 +1,74 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START firestore_v1beta1_generated_Firestore_GetDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + */ + // const name = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * Reads the document in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Reads the version of the document at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callGetDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await firestoreClient.getDocument(request); + console.log(response); + } + + callGetDocument(); + // [END firestore_v1beta1_generated_Firestore_GetDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js new file mode 100644 index 000000000..0f258dbc9 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js @@ -0,0 +1,72 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1beta1_generated_Firestore_ListCollectionIds_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * The maximum number of results to return. + */ + // const pageSize = 1234 + /** + * A page token. Must be a value from + * ListCollectionIdsResponse google.firestore.v1beta1.ListCollectionIdsResponse. + */ + // const pageToken = 'abc123' + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListCollectionIds() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await firestoreClient.listCollectionIdsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCollectionIds(); + // [END firestore_v1beta1_generated_Firestore_ListCollectionIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js new file mode 100644 index 000000000..76924b83a --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js @@ -0,0 +1,107 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, collectionId) { + // [START firestore_v1beta1_generated_Firestore_ListDocuments_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + */ + // const collectionId = 'abc123' + /** + * The maximum number of documents to return. + */ + // const pageSize = 1234 + /** + * The `next_page_token` value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + /** + * The order to sort results by. For example: `priority desc, name`. + */ + // const orderBy = 'abc123' + /** + * The fields to return. If not set, returns all fields. + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * Reads documents in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + /** + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, Document.create_time google.firestore.v1beta1.Document.create_time, + * or Document.update_time google.firestore.v1beta1.Document.update_time set. + * Requests with `show_missing` may not specify `where` or + * `order_by`. + */ + // const showMissing = true + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListDocuments() { + // Construct request + const request = { + parent, + collectionId, + }; + + // Run request + const iterable = await firestoreClient.listDocumentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDocuments(); + // [END firestore_v1beta1_generated_Firestore_ListDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js new file mode 100644 index 000000000..08248d7a5 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js @@ -0,0 +1,75 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_Listen_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * A target to add to this stream. + */ + // const addTarget = {} + /** + * The ID of a target to remove from this stream. + */ + // const removeTarget = 1234 + /** + * Labels associated with this target change. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callListen() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.listen(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callListen(); + // [END firestore_v1beta1_generated_Firestore_Listen_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js new file mode 100644 index 000000000..ab02276e6 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js @@ -0,0 +1,102 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1beta1_generated_Firestore_PartitionQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + */ + // const parent = 'abc123' + /** + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + */ + // const structuredQuery = {} + /** + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + */ + // const partitionCount = 1234 + /** + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * For example, two subsequent calls using a page_token may return: + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + */ + // const pageToken = 'abc123' + /** + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + */ + // const pageSize = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callPartitionQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await firestoreClient.partitionQueryAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callPartitionQuery(); + // [END firestore_v1beta1_generated_Firestore_PartitionQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js new file mode 100644 index 000000000..ace842326 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js @@ -0,0 +1,64 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database, transaction) { + // [START firestore_v1beta1_generated_Firestore_Rollback_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + */ + // const database = 'abc123' + /** + * Required. The transaction to roll back. + */ + // const transaction = 'Buffer.from('string')' + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRollback() { + // Construct request + const request = { + database, + transaction, + }; + + // Run request + const response = await firestoreClient.rollback(request); + console.log(response); + } + + callRollback(); + // [END firestore_v1beta1_generated_Firestore_Rollback_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js new file mode 100644 index 000000000..40fe4e2ea --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js @@ -0,0 +1,85 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START firestore_v1beta1_generated_Firestore_RunQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + */ + // const parent = 'abc123' + /** + * A structured query. + */ + // const structuredQuery = {} + /** + * Reads documents in a transaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRunQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const stream = await firestoreClient.runQuery(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callRunQuery(); + // [END firestore_v1beta1_generated_Firestore_RunQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js new file mode 100644 index 000000000..52b3b5e79 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js @@ -0,0 +1,79 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(document) { + // [START firestore_v1beta1_generated_Firestore_UpdateDocument_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The updated document. + * Creates the document if it does not already exist. + */ + // const document = {} + /** + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + */ + // const updateMask = {} + /** + * The fields to return. If not set, returns all fields. + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + */ + // const mask = {} + /** + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + */ + // const currentDocument = {} + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callUpdateDocument() { + // Construct request + const request = { + document, + }; + + // Run request + const response = await firestoreClient.updateDocument(request); + console.log(response); + } + + callUpdateDocument(); + // [END firestore_v1beta1_generated_Firestore_UpdateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js new file mode 100644 index 000000000..119d793fe --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js @@ -0,0 +1,95 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(database) { + // [START firestore_v1beta1_generated_Firestore_Write_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * This is only required in the first message. + */ + // const database = 'abc123' + /** + * The ID of the write stream to resume. + * This may only be set in the first message. When left empty, a new write + * stream will be created. + */ + // const streamId = 'abc123' + /** + * The writes to apply. + * Always executed atomically and in order. + * This must be empty on the first request. + * This may be empty on the last request. + * This must not be empty on all other requests. + */ + // const writes = 1234 + /** + * A stream token that was previously sent by the server. + * The client should set this field to the token from the most recent + * WriteResponse google.firestore.v1beta1.WriteResponse it has received. This acknowledges that the client has + * received responses up to this token. After sending this token, earlier + * tokens may not be used anymore. + * The server may close the stream if there are too many unacknowledged + * responses. + * Leave this field unset when creating a new stream. To resume a stream at + * a specific point, set this field and the `stream_id` field. + * Leave this field unset when creating a new stream. + */ + // const streamToken = 'Buffer.from('string')' + /** + * Labels associated with this write request. + */ + // const labels = 1234 + + // Imports the Firestore library + const {FirestoreClient} = require('firestore').v1beta1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callWrite() { + // Construct request + const request = { + database, + }; + + // Run request + const stream = await firestoreClient.write(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callWrite(); + // [END firestore_v1beta1_generated_Firestore_Write_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json new file mode 100644 index 000000000..a3e0b12be --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json @@ -0,0 +1,803 @@ +{ + "clientLibrary": { + "name": "nodejs-firestore", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.firestore.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "firestore_v1beta1_generated_Firestore_GetDocument_async", + "title": "Firestore getDocument Sample", + "origin": "API_DEFINITION", + "description": " Gets a single document.", + "canonical": true, + "file": "firestore.get_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocument", + "fullName": "google.firestore.v1beta1.Firestore.GetDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "mask", + "type": ".google.firestore.v1beta1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1beta1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "GetDocument", + "fullName": "google.firestore.v1beta1.Firestore.GetDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_ListDocuments_async", + "title": "Firestore listDocuments Sample", + "origin": "API_DEFINITION", + "description": " Lists documents.", + "canonical": true, + "file": "firestore.list_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 99, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDocuments", + "fullName": "google.firestore.v1beta1.Firestore.ListDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "collection_id", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "mask", + "type": ".google.firestore.v1beta1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "show_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.firestore.v1beta1.ListDocumentsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "ListDocuments", + "fullName": "google.firestore.v1beta1.Firestore.ListDocuments", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_UpdateDocument_async", + "title": "Firestore updateDocument Sample", + "origin": "API_DEFINITION", + "description": " Updates or inserts a document.", + "canonical": true, + "file": "firestore.update_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocument", + "fullName": "google.firestore.v1beta1.Firestore.UpdateDocument", + "async": true, + "parameters": [ + { + "name": "document", + "type": ".google.firestore.v1beta1.Document" + }, + { + "name": "update_mask", + "type": ".google.firestore.v1beta1.DocumentMask" + }, + { + "name": "mask", + "type": ".google.firestore.v1beta1.DocumentMask" + }, + { + "name": "current_document", + "type": ".google.firestore.v1beta1.Precondition" + } + ], + "resultType": ".google.firestore.v1beta1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "UpdateDocument", + "fullName": "google.firestore.v1beta1.Firestore.UpdateDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_DeleteDocument_async", + "title": "Firestore deleteDocument Sample", + "origin": "API_DEFINITION", + "description": " Deletes a document.", + "canonical": true, + "file": "firestore.delete_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocument", + "fullName": "google.firestore.v1beta1.Firestore.DeleteDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "current_document", + "type": ".google.firestore.v1beta1.Precondition" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "DeleteDocument", + "fullName": "google.firestore.v1beta1.Firestore.DeleteDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_BatchGetDocuments_async", + "title": "Firestore batchGetDocuments Sample", + "origin": "API_DEFINITION", + "description": " Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.", + "canonical": true, + "file": "firestore.batch_get_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchGetDocuments", + "fullName": "google.firestore.v1beta1.Firestore.BatchGetDocuments", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "documents", + "type": "TYPE_STRING[]" + }, + { + "name": "mask", + "type": ".google.firestore.v1beta1.DocumentMask" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1beta1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1beta1.BatchGetDocumentsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "BatchGetDocuments", + "fullName": "google.firestore.v1beta1.Firestore.BatchGetDocuments", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_BeginTransaction_async", + "title": "Firestore beginTransaction Sample", + "origin": "API_DEFINITION", + "description": " Starts a new transaction.", + "canonical": true, + "file": "firestore.begin_transaction.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BeginTransaction", + "fullName": "google.firestore.v1beta1.Firestore.BeginTransaction", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.firestore.v1beta1.TransactionOptions" + } + ], + "resultType": ".google.firestore.v1beta1.BeginTransactionResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "BeginTransaction", + "fullName": "google.firestore.v1beta1.Firestore.BeginTransaction", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_Commit_async", + "title": "Firestore commit Sample", + "origin": "API_DEFINITION", + "description": " Commits a transaction, while optionally updating documents.", + "canonical": true, + "file": "firestore.commit.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Commit", + "fullName": "google.firestore.v1beta1.Firestore.Commit", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.firestore.v1beta1.CommitResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "Commit", + "fullName": "google.firestore.v1beta1.Firestore.Commit", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_Rollback_async", + "title": "Firestore rollback Sample", + "origin": "API_DEFINITION", + "description": " Rolls back a transaction.", + "canonical": true, + "file": "firestore.rollback.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Rollback", + "fullName": "google.firestore.v1beta1.Firestore.Rollback", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "Rollback", + "fullName": "google.firestore.v1beta1.Firestore.Rollback", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_RunQuery_async", + "title": "Firestore runQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs a query.", + "canonical": true, + "file": "firestore.run_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunQuery", + "fullName": "google.firestore.v1beta1.Firestore.RunQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_query", + "type": ".google.firestore.v1beta1.StructuredQuery" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1beta1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1beta1.RunQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "RunQuery", + "fullName": "google.firestore.v1beta1.Firestore.RunQuery", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_PartitionQuery_async", + "title": "Firestore partitionQuery Sample", + "origin": "API_DEFINITION", + "description": " Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.", + "canonical": true, + "file": "firestore.partition_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 94, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PartitionQuery", + "fullName": "google.firestore.v1beta1.Firestore.PartitionQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_query", + "type": ".google.firestore.v1beta1.StructuredQuery" + }, + { + "name": "partition_count", + "type": "TYPE_INT64" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.firestore.v1beta1.PartitionQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "PartitionQuery", + "fullName": "google.firestore.v1beta1.Firestore.PartitionQuery", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_Write_async", + "title": "Firestore write Sample", + "origin": "API_DEFINITION", + "description": " Streams batches of document updates and deletes, in order.", + "canonical": true, + "file": "firestore.write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Write", + "fullName": "google.firestore.v1beta1.Firestore.Write", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "stream_id", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "stream_token", + "type": "TYPE_BYTES" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1beta1.WriteResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "Write", + "fullName": "google.firestore.v1beta1.Firestore.Write", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_Listen_async", + "title": "Firestore listen Sample", + "origin": "API_DEFINITION", + "description": " Listens to changes.", + "canonical": true, + "file": "firestore.listen.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Listen", + "fullName": "google.firestore.v1beta1.Firestore.Listen", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "add_target", + "type": ".google.firestore.v1beta1.Target" + }, + { + "name": "remove_target", + "type": "TYPE_INT32" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1beta1.ListenResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "Listen", + "fullName": "google.firestore.v1beta1.Firestore.Listen", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_ListCollectionIds_async", + "title": "Firestore listCollectionIds Sample", + "origin": "API_DEFINITION", + "description": " Lists all the collection IDs underneath a document.", + "canonical": true, + "file": "firestore.list_collection_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCollectionIds", + "fullName": "google.firestore.v1beta1.Firestore.ListCollectionIds", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.firestore.v1beta1.ListCollectionIdsResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "ListCollectionIds", + "fullName": "google.firestore.v1beta1.Firestore.ListCollectionIds", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_BatchWrite_async", + "title": "Firestore batchWrite Sample", + "origin": "API_DEFINITION", + "description": " Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write. If you require an atomically applied set of writes, use [Commit][google.firestore.v1beta1.Firestore.Commit] instead.", + "canonical": true, + "file": "firestore.batch_write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchWrite", + "fullName": "google.firestore.v1beta1.Firestore.BatchWrite", + "async": true, + "parameters": [ + { + "name": "database", + "type": "TYPE_STRING" + }, + { + "name": "writes", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.firestore.v1beta1.BatchWriteResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "BatchWrite", + "fullName": "google.firestore.v1beta1.Firestore.BatchWrite", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + }, + { + "regionTag": "firestore_v1beta1_generated_Firestore_CreateDocument_async", + "title": "Firestore createDocument Sample", + "origin": "API_DEFINITION", + "description": " Creates a new document.", + "canonical": true, + "file": "firestore.create_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocument", + "fullName": "google.firestore.v1beta1.Firestore.CreateDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "collection_id", + "type": "TYPE_STRING" + }, + { + "name": "document_id", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.firestore.v1beta1.Document" + }, + { + "name": "mask", + "type": ".google.firestore.v1beta1.DocumentMask" + } + ], + "resultType": ".google.firestore.v1beta1.Document", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1beta1.FirestoreClient" + }, + "method": { + "shortName": "CreateDocument", + "fullName": "google.firestore.v1beta1.Firestore.CreateDocument", + "service": { + "shortName": "Firestore", + "fullName": "google.firestore.v1beta1.Firestore" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 000000000..37c81a4b8 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const FirestoreClient = v1beta1.FirestoreClient; +type FirestoreClient = v1beta1.FirestoreClient; +export {v1beta1, FirestoreClient}; +export default {v1beta1, FirestoreClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts new file mode 100644 index 000000000..b811e25f7 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts @@ -0,0 +1,1855 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, GoogleError} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import { PassThrough } from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/firestore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './firestore_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * The Cloud Firestore service. + * + * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL + * document database that simplifies storing, syncing, and querying data for + * your mobile, web, and IoT apps at global scale. Its client libraries provide + * live synchronization and offline support, while its security features and + * integrations with Firebase and Google Cloud Platform (GCP) accelerate + * building truly serverless apps. + * @class + * @memberof v1beta1 + */ +export class FirestoreClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + firestoreStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FirestoreClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof FirestoreClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDocuments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'), + partitionQuery: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'), + listCollectionIds: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds') + }; + + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), + write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), + listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.firestore.v1beta1.Firestore', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.firestoreStub) { + return this.firestoreStub; + } + + // Put together the "service stub" for + // google.firestore.v1beta1.Firestore. + this.firestoreStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.firestore.v1beta1.Firestore') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.firestore.v1beta1.Firestore, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const firestoreStubMethods = + ['getDocument', 'listDocuments', 'updateDocument', 'deleteDocument', 'batchGetDocuments', 'beginTransaction', 'commit', 'rollback', 'runQuery', 'partitionQuery', 'write', 'listen', 'listCollectionIds', 'batchWrite', 'createDocument']; + for (const methodName of firestoreStubMethods) { + const callPromise = this.firestoreStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit('error', new GoogleError('The client has already been closed.')); + }); + return stream; + } + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.firestoreStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'firestore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'firestore.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to get. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads the document in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads the version of the document at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.get_document.js + * region_tag:firestore_v1beta1_generated_Firestore_GetDocument_async + */ + getDocument( + request?: protos.google.firestore.v1beta1.IGetDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|undefined, {}|undefined + ]>; + getDocument( + request: protos.google.firestore.v1beta1.IGetDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request: protos.google.firestore.v1beta1.IGetDocumentRequest, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request?: protos.google.firestore.v1beta1.IGetDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IGetDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getDocument(request, options, callback); + } +/** + * Updates or inserts a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.firestore.v1beta1.Document} request.document + * Required. The updated document. + * Creates the document if it does not already exist. + * @param {google.firestore.v1beta1.DocumentMask} request.updateMask + * The fields to update. + * None of the field paths in the mask may contain a reserved name. + * + * If the document exists on the server and has fields not referenced in the + * mask, they are left unchanged. + * Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {google.firestore.v1beta1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.update_document.js + * region_tag:firestore_v1beta1_generated_Firestore_UpdateDocument_async + */ + updateDocument( + request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|undefined, {}|undefined + ]>; + updateDocument( + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.IUpdateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'document.name': request.document!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateDocument(request, options, callback); + } +/** + * Deletes a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @param {google.firestore.v1beta1.Precondition} request.currentDocument + * An optional precondition on the document. + * The request will fail if this is set and not met by the target document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.delete_document.js + * region_tag:firestore_v1beta1_generated_Firestore_DeleteDocument_async + */ + deleteDocument( + request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|undefined, {}|undefined + ]>; + deleteDocument( + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IDeleteDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteDocument(request, options, callback); + } +/** + * Starts a new transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {google.firestore.v1beta1.TransactionOptions} request.options + * The options for the transaction. + * Defaults to a read-write transaction. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.begin_transaction.js + * region_tag:firestore_v1beta1_generated_Firestore_BeginTransaction_async + */ + beginTransaction( + request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|undefined, {}|undefined + ]>; + beginTransaction( + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request: protos.google.firestore.v1beta1.IBeginTransactionRequest, + callback: Callback< + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.IBeginTransactionResponse, + protos.google.firestore.v1beta1.IBeginTransactionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.beginTransaction(request, options, callback); + } +/** + * Commits a transaction, while optionally updating documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {number[]} request.writes + * The writes to apply. + * + * Always executed atomically and in order. + * @param {Buffer} request.transaction + * If set, applies all writes in this transaction, and commits it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.commit.js + * region_tag:firestore_v1beta1_generated_Firestore_Commit_async + */ + commit( + request?: protos.google.firestore.v1beta1.ICommitRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|undefined, {}|undefined + ]>; + commit( + request: protos.google.firestore.v1beta1.ICommitRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request: protos.google.firestore.v1beta1.ICommitRequest, + callback: Callback< + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request?: protos.google.firestore.v1beta1.ICommitRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.ICommitResponse, + protos.google.firestore.v1beta1.ICommitRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.commit(request, options, callback); + } +/** + * Rolls back a transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {Buffer} request.transaction + * Required. The transaction to roll back. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.rollback.js + * region_tag:firestore_v1beta1_generated_Firestore_Rollback_async + */ + rollback( + request?: protos.google.firestore.v1beta1.IRollbackRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|undefined, {}|undefined + ]>; + rollback( + request: protos.google.firestore.v1beta1.IRollbackRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request: protos.google.firestore.v1beta1.IRollbackRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request?: protos.google.firestore.v1beta1.IRollbackRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.firestore.v1beta1.IRollbackRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.rollback(request, options, callback); + } +/** + * Applies a batch of write operations. + * + * The BatchWrite method does not apply the write operations atomically + * and can apply them out of order. Method does not allow more than one write + * per document. Each write succeeds or fails independently. See the + * {@link google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link google.firestore.v1beta1.Firestore.Commit|Commit} instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {number[]} request.writes + * The writes to apply. + * + * Method does not apply writes atomically and does not guarantee ordering. + * Each write succeeds or fails independently. You cannot write to the same + * document more than once per request. + * @param {number[]} request.labels + * Labels associated with this batch write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BatchWriteResponse]{@link google.firestore.v1beta1.BatchWriteResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.batch_write.js + * region_tag:firestore_v1beta1_generated_Firestore_BatchWrite_async + */ + batchWrite( + request?: protos.google.firestore.v1beta1.IBatchWriteRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|undefined, {}|undefined + ]>; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): void; + batchWrite( + request: protos.google.firestore.v1beta1.IBatchWriteRequest, + callback: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): void; + batchWrite( + request?: protos.google.firestore.v1beta1.IBatchWriteRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.IBatchWriteResponse, + protos.google.firestore.v1beta1.IBatchWriteRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.batchWrite(request, options, callback); + } +/** + * Creates a new document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource. For example: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. + * @param {string} request.documentId + * The client-assigned document ID to use for this document. + * + * Optional. If not specified, an ID will be assigned by the service. + * @param {google.firestore.v1beta1.Document} request.document + * Required. The document to create. `name` must not be set. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If the document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.create_document.js + * region_tag:firestore_v1beta1_generated_Firestore_CreateDocument_async + */ + createDocument( + request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|undefined, {}|undefined + ]>; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request: protos.google.firestore.v1beta1.ICreateDocumentRequest, + callback: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.firestore.v1beta1.IDocument, + protos.google.firestore.v1beta1.ICreateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createDocument(request, options, callback); + } + +/** + * Gets multiple documents. + * + * Documents returned by this method are not guaranteed to be returned in the + * same order that they were requested. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param {string[]} request.documents + * The names of the documents to retrieve. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * The request will fail if any of the document is not a child resource of the + * given `database`. Duplicate names will be elided. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field will + * not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.batch_get_documents.js + * region_tag:firestore_v1beta1_generated_Firestore_BatchGetDocuments_async + */ + batchGetDocuments( + request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'database': request.database || '', + }); + this.initialize(); + return this.innerApiCalls.batchGetDocuments(request, options); + } + +/** + * Runs a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction + * Starts a new transaction and reads the documents. + * Defaults to a read-only transaction. + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.run_query.js + * region_tag:firestore_v1beta1_generated_Firestore_RunQuery_async + */ + runQuery( + request?: protos.google.firestore.v1beta1.IRunQueryRequest, + options?: CallOptions): + gax.CancellableStream{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.runQuery(request, options); + } + +/** + * Streams batches of document updates and deletes, in order. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and + * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.write.js + * region_tag:firestore_v1beta1_generated_Firestore_Write_async + */ + write( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.write(null, options); + } + +/** + * Listens to changes. + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and + * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.listen.js + * region_tag:firestore_v1beta1_generated_Firestore_Listen_async + */ + listen( + options?: CallOptions): + gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.listen(null, options); + } + + /** + * Lists documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Document]{@link google.firestore.v1beta1.Document}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocuments( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.IDocument[], + protos.google.firestore.v1beta1.IListDocumentsRequest|null, + protos.google.firestore.v1beta1.IListDocumentsResponse + ]>; + listDocuments( + request: protos.google.firestore.v1beta1.IListDocumentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1beta1.IDocument>): void; + listDocuments( + request: protos.google.firestore.v1beta1.IListDocumentsRequest, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1beta1.IDocument>): void; + listDocuments( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1beta1.IDocument>, + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IListDocumentsRequest, + protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, + protos.google.firestore.v1beta1.IDocument>): + Promise<[ + protos.google.firestore.v1beta1.IDocument[], + protos.google.firestore.v1beta1.IListDocumentsRequest|null, + protos.google.firestore.v1beta1.IListDocumentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listDocuments(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDocumentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDocumentsStream( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDocuments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents` or + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents` or + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {string} request.collectionId + * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` + * or `messages`. + * @param {number} request.pageSize + * The maximum number of documents to return. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous List request, if any. + * @param {string} request.orderBy + * The order to sort results by. For example: `priority desc, name`. + * @param {google.firestore.v1beta1.DocumentMask} request.mask + * The fields to return. If not set, returns all fields. + * + * If a document has a field that is not present in this mask, that field + * will not be returned in the response. + * @param {Buffer} request.transaction + * Reads documents in a transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * This may not be older than 270 seconds. + * @param {boolean} request.showMissing + * If the list should show missing documents. A missing document is a + * document that does not exist but has sub-documents. These documents will + * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. + * + * Requests with `show_missing` may not specify `where` or + * `order_by`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Document]{@link google.firestore.v1beta1.Document}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.list_documents.js + * region_tag:firestore_v1beta1_generated_Firestore_ListDocuments_async + */ + listDocumentsAsync( + request?: protos.google.firestore.v1beta1.IListDocumentsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.asyncIterate( + this.innerApiCalls['listDocuments'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Partitions a query by returning partition cursors that can be used to run + * the query in parallel. The returned partition cursors are split points that + * can be used by RunQuery as starting/end points for the query results. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Cursor]{@link google.firestore.v1beta1.Cursor}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQuery( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.firestore.v1beta1.ICursor[], + protos.google.firestore.v1beta1.IPartitionQueryRequest|null, + protos.google.firestore.v1beta1.IPartitionQueryResponse + ]>; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1beta1.ICursor>): void; + partitionQuery( + request: protos.google.firestore.v1beta1.IPartitionQueryRequest, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1beta1.ICursor>): void; + partitionQuery( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1beta1.ICursor>, + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IPartitionQueryRequest, + protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, + protos.google.firestore.v1beta1.ICursor>): + Promise<[ + protos.google.firestore.v1beta1.ICursor[], + protos.google.firestore.v1beta1.IPartitionQueryRequest|null, + protos.google.firestore.v1beta1.IPartitionQueryResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.partitionQuery(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Cursor]{@link google.firestore.v1beta1.Cursor} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `partitionQueryAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + partitionQueryStream( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['partitionQuery']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.partitionQuery.createStream( + this.innerApiCalls.partitionQuery as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `partitionQuery`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name. In the format: + * `projects/{project_id}/databases/{database_id}/documents`. + * Document resource names are not supported; only database resource names + * can be specified. + * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery + * A structured query. + * Query must specify collection with all descendants and be ordered by name + * ascending. Other filters, order bys, limits, offsets, and start/end + * cursors are not supported. + * @param {number} request.partitionCount + * The desired maximum number of partition points. + * The partitions may be returned across multiple pages of results. + * The number must be positive. The actual number of partitions + * returned may be fewer. + * + * For example, this may be set to one fewer than the number of parallel + * queries to be run, or in running a data pipeline job, one fewer than the + * number of workers or compute instances available. + * @param {string} request.pageToken + * The `next_page_token` value returned from a previous call to + * PartitionQuery that may be used to get an additional set of results. + * There are no ordering guarantees between sets of results. Thus, using + * multiple sets of results will require merging the different result sets. + * + * For example, two subsequent calls using a page_token may return: + * + * * cursor B, cursor M, cursor Q + * * cursor A, cursor U, cursor W + * + * To obtain a complete result set ordered with respect to the results of the + * query supplied to PartitionQuery, the results sets should be merged: + * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + * @param {number} request.pageSize + * The maximum number of partitions to return in this call, subject to + * `partition_count`. + * + * For example, if `partition_count` = 10 and `page_size` = 8, the first call + * to PartitionQuery will return up to 8 partitions and a `next_page_token` + * 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`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Cursor]{@link google.firestore.v1beta1.Cursor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.partition_query.js + * region_tag:firestore_v1beta1_generated_Firestore_PartitionQuery_async + */ + partitionQueryAsync( + request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['partitionQuery']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.partitionQuery.asyncIterate( + this.innerApiCalls['partitionQuery'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Lists all the collection IDs underneath a document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIds( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions): + Promise<[ + string[], + protos.google.firestore.v1beta1.IListCollectionIdsRequest|null, + protos.google.firestore.v1beta1.IListCollectionIdsResponse + ]>; + listCollectionIds( + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, + string>): void; + listCollectionIds( + request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + callback: PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, + string>): void; + listCollectionIds( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, + string>, + callback?: PaginationCallback< + protos.google.firestore.v1beta1.IListCollectionIdsRequest, + protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, + string>): + Promise<[ + string[], + protos.google.firestore.v1beta1.IListCollectionIdsRequest|null, + protos.google.firestore.v1beta1.IListCollectionIdsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCollectionIds(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCollectionIdsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCollectionIdsStream( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCollectionIds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectionIds.createStream( + this.innerApiCalls.listCollectionIds as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listCollectionIds`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @param {number} request.pageSize + * The maximum number of results to return. + * @param {string} request.pageToken + * A page token. Must be a value from + * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta1/firestore.list_collection_ids.js + * region_tag:firestore_v1beta1_generated_Firestore_ListCollectionIds_async + */ + listCollectionIdsAsync( + request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listCollectionIds']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCollectionIds.asyncIterate( + this.innerApiCalls['listCollectionIds'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.firestoreStub && !this._terminated) { + return this.firestoreStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json new file mode 100644 index 000000000..b0366d662 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.firestore.v1beta1.Firestore": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "GetDocument": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteDocument": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchGetDocuments": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BeginTransaction": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "Commit": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Rollback": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunQuery": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PartitionQuery": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Write": { + "timeout_millis": 86400000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Listen": { + "timeout_millis": 86400000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListCollectionIds": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchWrite": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateDocument": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json new file mode 100644 index 000000000..fbbd4aecc --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/firestore/v1beta1/common.proto", + "../../protos/google/firestore/v1beta1/document.proto", + "../../protos/google/firestore/v1beta1/firestore.proto", + "../../protos/google/firestore/v1beta1/query.proto", + "../../protos/google/firestore/v1beta1/write.proto" +] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 000000000..45483c761 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,165 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.firestore.v1beta1", + "libraryPackage": "firestore", + "services": { + "Firestore": { + "clients": { + "grpc": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "BatchGetDocuments": { + "methods": [ + "batchGetDocuments" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "Write": { + "methods": [ + "write" + ] + }, + "Listen": { + "methods": [ + "listen" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FirestoreClient", + "rpcs": { + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "BatchWrite": { + "methods": [ + "batchWrite" + ] + }, + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "ListDocuments": { + "methods": [ + "listDocuments", + "listDocumentsStream", + "listDocumentsAsync" + ] + }, + "PartitionQuery": { + "methods": [ + "partitionQuery", + "partitionQueryStream", + "partitionQueryAsync" + ] + }, + "ListCollectionIds": { + "methods": [ + "listCollectionIds", + "listCollectionIdsStream", + "listCollectionIdsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts new file mode 100644 index 000000000..80ccfc089 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {FirestoreClient} from './firestore_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..0b7733350 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const firestore = require('firestore'); + +function main() { + const firestoreClient = new firestore.FirestoreClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..174db19ce --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {FirestoreClient} from 'firestore'; + +// check that the client class type name can be used +function doStuffWithFirestoreClient(client: FirestoreClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const firestoreClient = new FirestoreClient(); + doStuffWithFirestoreClient(firestoreClient); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts new file mode 100644 index 000000000..8ec452229 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts new file mode 100644 index 000000000..71f7bf8dc --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts @@ -0,0 +1,1928 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as firestoreModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubServerStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // write something to the stream to trigger transformStub and send the response back to the client + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + return sinon.stub().returns(mockStream); +} + +function stubBidiStreamingCall(response?: ResponseType, error?: Error) { + const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta1.FirestoreClient', () => { + it('has servicePath', () => { + const servicePath = firestoreModule.v1beta1.FirestoreClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = firestoreModule.v1beta1.FirestoreClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = firestoreModule.v1beta1.FirestoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new firestoreModule.v1beta1.FirestoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + await client.initialize(); + assert(client.firestoreStub); + }); + + it('has close method for the initialized client', done => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.firestoreStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.firestoreStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDocument with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + assert((client.innerApiCalls.getDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDocument with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocument(request), expectedError); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateDocument with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedHeaderRequestParams = "document.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + assert((client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDocument with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); + request.document = {}; + request.document.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocument(request), expectedError); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteDocument with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + assert((client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDocument with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocument(request), expectedError); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IBeginTransactionResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes beginTransaction with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.beginTransaction(request), expectedError); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.ICommitResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes commit with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.commit(request), expectedError); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rollback with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollback(request), expectedError); + }); + }); + + describe('batchWrite', () => { + it('invokes batchWrite without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteResponse()); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchWrite without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteResponse()); + client.innerApiCalls.batchWrite = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchWrite( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IBatchWriteResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchWrite with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + assert((client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchWrite with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchWrite(request), expectedError); + }); + }); + + describe('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createDocument with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + assert((client.innerApiCalls.createDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDocument with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocument(request), expectedError); + }); + }); + + describe('batchGetDocuments', () => { + it('invokes batchGetDocuments without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsResponse()); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(expectedResponse); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes batchGetDocuments with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedHeaderRequestParams = "database="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(undefined, expectedError); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes batchGetDocuments with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); + request.database = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryResponse()); + client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes runQuery with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubServerStreamingCall(undefined, expectedError); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions)); + }); + + it('invokes runQuery with closed client', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); + }); + + describe('write', () => { + it('invokes write without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.WriteRequest()); + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.WriteResponse()); + client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.WriteResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.write as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes write with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.WriteRequest()); + const expectedError = new Error('expected'); + client.innerApiCalls.write = stubBidiStreamingCall(undefined, expectedError); + const stream = client.write(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.WriteResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.write as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('listen', () => { + it('invokes listen without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListenRequest()); + const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.ListenResponse()); + client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.ListenResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listen as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + + it('invokes listen with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListenRequest()); + const expectedError = new Error('expected'); + client.innerApiCalls.listen = stubBidiStreamingCall(undefined, expectedError); + const stream = client.listen(); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1beta1.ListenResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert((client.innerApiCalls.listen as SinonStub) + .getCall(0).calledWith(null)); + assert.deepStrictEqual(((stream as unknown as PassThrough) + ._transform as SinonStub).getCall(0).args[0], request); + }); + }); + + describe('listDocuments', () => { + it('invokes listDocuments without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.listDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDocuments without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDocuments( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDocuments with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + assert((client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDocumentsStream without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1beta1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert.strictEqual( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listDocumentsStream with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Document[] = []; + stream.on('data', (response: protos.google.firestore.v1beta1.Document) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); + assert.strictEqual( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + generateSampleMessage(new protos.google.firestore.v1beta1.Document()), + ]; + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.v1beta1.IDocument[] = []; + const iterable = client.listDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDocuments with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1beta1.IDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('partitionQuery', () => { + it('invokes partitionQuery without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); + const [response] = await client.partitionQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes partitionQuery without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partitionQuery( + request, + (err?: Error|null, result?: protos.google.firestore.v1beta1.ICursor[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes partitionQuery with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + assert((client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes partitionQueryStream without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1beta1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); + assert.strictEqual( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes partitionQueryStream with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.partitionQueryStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.firestore.v1beta1.Cursor[] = []; + stream.on('data', (response: protos.google.firestore.v1beta1.Cursor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); + assert.strictEqual( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), + ]; + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.firestore.v1beta1.ICursor[] = []; + const iterable = client.partitionQueryAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with partitionQuery with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.partitionQueryAsync(request); + await assert.rejects(async () => { + const responses: protos.google.firestore.v1beta1.ICursor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCollectionIds', () => { + it('invokes listCollectionIds without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCollectionIds without error using callback', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCollectionIds( + request, + (err?: Error|null, result?: string[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listCollectionIds with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + assert((client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listCollectionIdsStream without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listCollectionIdsStream with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listCollectionIdsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds without error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.listCollectionIdsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCollectionIds with error', async () => { + const client = new firestoreModule.v1beta1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCollectionIdsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js new file mode 100644 index 000000000..1b321882d --- /dev/null +++ b/owl-bot-staging/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'Firestore', + filename: './firestore.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From bcfe16c7c884fc3ced1c1ffb9e1fa0cdd6eb2382 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 27 Apr 2022 17:50:55 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google/firestore/v1/firestore.proto | 9 + owl-bot-staging/admin/v1/.eslintignore | 7 - owl-bot-staging/admin/v1/.eslintrc.json | 3 - owl-bot-staging/admin/v1/.gitignore | 14 - owl-bot-staging/admin/v1/.jsdoc.js | 55 - owl-bot-staging/admin/v1/.mocharc.js | 33 - owl-bot-staging/admin/v1/.prettierrc.js | 22 - owl-bot-staging/admin/v1/README.md | 1 - .../admin/v1/linkinator.config.json | 16 - owl-bot-staging/admin/v1/package.json | 64 - .../google/firestore/admin/v1/database.proto | 98 - .../google/firestore/admin/v1/field.proto | 100 - .../firestore/admin/v1/firestore_admin.proto | 459 ---- .../google/firestore/admin/v1/index.proto | 157 -- .../google/firestore/admin/v1/location.proto | 34 - .../google/firestore/admin/v1/operation.proto | 203 -- .../v1/firestore_admin.create_index.js | 65 - .../v1/firestore_admin.delete_index.js | 59 - .../v1/firestore_admin.export_documents.js | 75 - .../v1/firestore_admin.get_database.js | 59 - .../generated/v1/firestore_admin.get_field.js | 59 - .../generated/v1/firestore_admin.get_index.js | 59 - .../v1/firestore_admin.import_documents.js | 73 - .../v1/firestore_admin.list_databases.js | 59 - .../v1/firestore_admin.list_fields.js | 79 - .../v1/firestore_admin.list_indexes.js | 75 - .../v1/firestore_admin.update_database.js | 63 - .../v1/firestore_admin.update_field.js | 64 - ...et_metadata.google.firestore.admin.v1.json | 547 ----- owl-bot-staging/admin/v1/src/index.ts | 25 - .../admin/v1/src/v1/firestore_admin_client.ts | 1914 --------------- .../src/v1/firestore_admin_client_config.json | 88 - .../v1/src/v1/firestore_admin_proto_list.json | 8 - .../admin/v1/src/v1/gapic_metadata.json | 151 -- owl-bot-staging/admin/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../admin/v1/system-test/install.ts | 49 - .../admin/v1/test/gapic_firestore_admin_v1.ts | 2082 ----------------- owl-bot-staging/admin/v1/tsconfig.json | 19 - owl-bot-staging/admin/v1/webpack.config.js | 64 - owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 64 - .../protos/google/firestore/v1/common.proto | 82 - .../protos/google/firestore/v1/document.proto | 149 -- .../google/firestore/v1/firestore.proto | 912 -------- .../v1/protos/google/firestore/v1/query.proto | 304 --- .../v1/protos/google/firestore/v1/write.proto | 258 -- .../v1/firestore.batch_get_documents.js | 90 - .../generated/v1/firestore.batch_write.js | 70 - .../v1/firestore.begin_transaction.js | 64 - .../samples/generated/v1/firestore.commit.js | 68 - .../generated/v1/firestore.create_document.js | 81 - .../generated/v1/firestore.delete_document.js | 64 - .../generated/v1/firestore.get_document.js | 74 - .../v1/firestore.list_collection_ids.js | 72 - .../generated/v1/firestore.list_documents.js | 107 - .../samples/generated/v1/firestore.listen.js | 75 - .../generated/v1/firestore.partition_query.js | 102 - .../generated/v1/firestore.rollback.js | 64 - .../generated/v1/firestore.run_query.js | 86 - .../generated/v1/firestore.update_document.js | 79 - .../samples/generated/v1/firestore.write.js | 95 - .../snippet_metadata.google.firestore.v1.json | 803 ------- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/firestore_client.ts | 1857 --------------- .../v1/src/v1/firestore_client_config.json | 116 - .../v1/src/v1/firestore_proto_list.json | 7 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 165 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - owl-bot-staging/v1/test/gapic_firestore_v1.ts | 1928 --------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta1/.eslintignore | 7 - owl-bot-staging/v1beta1/.eslintrc.json | 3 - owl-bot-staging/v1beta1/.gitignore | 14 - owl-bot-staging/v1beta1/.jsdoc.js | 55 - owl-bot-staging/v1beta1/.mocharc.js | 33 - owl-bot-staging/v1beta1/.prettierrc.js | 22 - owl-bot-staging/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 16 - owl-bot-staging/v1beta1/package.json | 64 - .../google/firestore/v1beta1/common.proto | 83 - .../google/firestore/v1beta1/document.proto | 150 -- .../google/firestore/v1beta1/firestore.proto | 900 ------- .../google/firestore/v1beta1/query.proto | 301 --- .../google/firestore/v1beta1/write.proto | 259 -- .../v1beta1/firestore.batch_get_documents.js | 90 - .../v1beta1/firestore.batch_write.js | 70 - .../v1beta1/firestore.begin_transaction.js | 64 - .../generated/v1beta1/firestore.commit.js | 68 - .../v1beta1/firestore.create_document.js | 81 - .../v1beta1/firestore.delete_document.js | 64 - .../v1beta1/firestore.get_document.js | 74 - .../v1beta1/firestore.list_collection_ids.js | 72 - .../v1beta1/firestore.list_documents.js | 107 - .../generated/v1beta1/firestore.listen.js | 75 - .../v1beta1/firestore.partition_query.js | 102 - .../generated/v1beta1/firestore.rollback.js | 64 - .../generated/v1beta1/firestore.run_query.js | 85 - .../v1beta1/firestore.update_document.js | 79 - .../generated/v1beta1/firestore.write.js | 95 - ...pet_metadata.google.firestore.v1beta1.json | 803 ------- owl-bot-staging/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/firestore_client.ts | 1855 --------------- .../src/v1beta1/firestore_client_config.json | 99 - .../src/v1beta1/firestore_proto_list.json | 7 - .../v1beta1/src/v1beta1/gapic_metadata.json | 165 -- owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - .../v1beta1/test/gapic_firestore_v1beta1.ts | 1928 --------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - 125 files changed, 9 insertions(+), 23492 deletions(-) delete mode 100644 owl-bot-staging/admin/v1/.eslintignore delete mode 100644 owl-bot-staging/admin/v1/.eslintrc.json delete mode 100644 owl-bot-staging/admin/v1/.gitignore delete mode 100644 owl-bot-staging/admin/v1/.jsdoc.js delete mode 100644 owl-bot-staging/admin/v1/.mocharc.js delete mode 100644 owl-bot-staging/admin/v1/.prettierrc.js delete mode 100644 owl-bot-staging/admin/v1/README.md delete mode 100644 owl-bot-staging/admin/v1/linkinator.config.json delete mode 100644 owl-bot-staging/admin/v1/package.json delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json delete mode 100644 owl-bot-staging/admin/v1/src/index.ts delete mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts delete mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/admin/v1/system-test/install.ts delete mode 100644 owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts delete mode 100644 owl-bot-staging/admin/v1/tsconfig.json delete mode 100644 owl-bot-staging/admin/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/common.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/document.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/query.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/write.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.commit.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.listen.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/firestore.write.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/firestore_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/firestore_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/firestore_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_firestore_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta1/.gitignore delete mode 100644 owl-bot-staging/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta1/README.md delete mode 100644 owl-bot-staging/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta1/package.json delete mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js delete mode 100644 owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json delete mode 100644 owl-bot-staging/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1beta1/webpack.config.js diff --git a/dev/protos/google/firestore/v1/firestore.proto b/dev/protos/google/firestore/v1/firestore.proto index 6dc663828..17c94ecb4 100644 --- a/dev/protos/google/firestore/v1/firestore.proto +++ b/dev/protos/google/firestore/v1/firestore.proto @@ -523,6 +523,15 @@ message RunQueryResponse { // The number of results that have been skipped due to an offset between // the last response and the current response. int32 skipped_results = 4; + + // The continuation mode for the query. If present, it indicates the current + // query response stream has finished. This can be set with or without a + // `document` present, but when set, no more results are returned. + oneof continuation_selector { + // If present, Firestore has completely finished the request and no more + // documents will be returned. + bool done = 6; + } } // The request for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. diff --git a/owl-bot-staging/admin/v1/.eslintignore b/owl-bot-staging/admin/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/admin/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/admin/v1/.eslintrc.json b/owl-bot-staging/admin/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/admin/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/admin/v1/.gitignore b/owl-bot-staging/admin/v1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/admin/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/admin/v1/.jsdoc.js b/owl-bot-staging/admin/v1/.jsdoc.js deleted file mode 100644 index accb86877..000000000 --- a/owl-bot-staging/admin/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/firestore-admin', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/admin/v1/.mocharc.js b/owl-bot-staging/admin/v1/.mocharc.js deleted file mode 100644 index 481c522b0..000000000 --- a/owl-bot-staging/admin/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/admin/v1/.prettierrc.js b/owl-bot-staging/admin/v1/.prettierrc.js deleted file mode 100644 index 494e14786..000000000 --- a/owl-bot-staging/admin/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/admin/v1/README.md b/owl-bot-staging/admin/v1/README.md deleted file mode 100644 index 5d45b74ed..000000000 --- a/owl-bot-staging/admin/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Admin: Nodejs Client diff --git a/owl-bot-staging/admin/v1/linkinator.config.json b/owl-bot-staging/admin/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/admin/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/admin/v1/package.json b/owl-bot-staging/admin/v1/package.json deleted file mode 100644 index a2ffae1ee..000000000 --- a/owl-bot-staging/admin/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/firestore-admin", - "version": "0.1.0", - "description": "Admin client for Node.js", - "repository": "googleapis/nodejs-admin", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google admin", - "admin", - "firestore admin" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto deleted file mode 100644 index 5b2cd7b6c..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -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"; -option java_multiple_files = true; -option java_outer_classname = "DatabaseProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; - -// A Cloud Firestore Database. -// Currently only one database is allowed per cloud project; this database -// must have a `database_id` of '(default)'. -message Database { - option (google.api.resource) = { - type: "firestore.googleapis.com/Database" - pattern: "projects/{project}/databases/{database}" - style: DECLARATIVE_FRIENDLY - }; - - // The type of the database. - // See https://cloud.google.com/datastore/docs/firestore-or-datastore for - // information about how to choose. - enum DatabaseType { - // The default value. This value is used if the database type is omitted. - DATABASE_TYPE_UNSPECIFIED = 0; - - // Firestore Native Mode - FIRESTORE_NATIVE = 1; - - // Firestore in Datastore Mode. - DATASTORE_MODE = 2; - } - - // The type of concurrency control mode for transactions. - enum ConcurrencyMode { - // Not used. - CONCURRENCY_MODE_UNSPECIFIED = 0; - - // Use optimistic concurrency control by default. This setting is available - // for Cloud Firestore customers. - OPTIMISTIC = 1; - - // Use pessimistic concurrency control by default. This setting is available - // for Cloud Firestore customers. - // 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. - OPTIMISTIC_WITH_ENTITY_GROUPS = 3; - } - - // The resource name of the Database. - // Format: `projects/{project}/databases/{database}` - string name = 1; - - // The location of the database. Available databases are listed at - // https://cloud.google.com/firestore/docs/locations. - string location_id = 9; - - // The type of the database. - // See https://cloud.google.com/datastore/docs/firestore-or-datastore for - // information about how to choose. - DatabaseType type = 10; - - // The concurrency control mode to use for this database. - ConcurrencyMode concurrency_mode = 15; - - // 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. - string etag = 99; -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto deleted file mode 100644 index 3e4224395..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -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"; -option java_multiple_files = true; -option java_outer_classname = "FieldProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; - -// Represents a single field in the database. -// -// Fields are grouped by their "Collection Group", which represent all -// collections in the database with the same id. -message Field { - option (google.api.resource) = { - type: "firestore.googleapis.com/Field" - pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" - }; - - // The index configuration for this field. - message IndexConfig { - // The indexes supported for this field. - repeated Index indexes = 1; - - // Output only. When true, the `Field`'s index configuration is set from the - // configuration specified by the `ancestor_field`. - // When false, the `Field`'s index configuration is defined explicitly. - bool uses_ancestor_config = 2; - - // Output only. Specifies the resource name of the `Field` from which this field's - // index configuration is set (when `uses_ancestor_config` is true), - // or from which it *would* be set if this field had no index configuration - // (when `uses_ancestor_config` is false). - string ancestor_field = 3; - - // Output only - // When true, the `Field`'s index configuration is in the process of being - // reverted. Once complete, the index config will transition to the same - // state as the field specified by `ancestor_field`, at which point - // `uses_ancestor_config` will be `true` and `reverting` will be `false`. - bool reverting = 4; - } - - // 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]; - - // 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. - IndexConfig index_config = 2; -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto deleted file mode 100644 index 772ea214b..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto +++ /dev/null @@ -1,459 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.admin.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -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"; -option java_multiple_files = true; -option java_outer_classname = "FirestoreAdminProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; -option (google.api.resource_definition) = { - type: "firestore.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; -option (google.api.resource_definition) = { - type: "firestore.googleapis.com/CollectionGroup" - pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}" -}; - -// The Cloud Firestore Admin API. -// -// This API provides several administrative services for Cloud Firestore. -// -// Project, Database, Namespace, Collection, Collection Group, and Document are -// used as defined in the Google Cloud Firestore API. -// -// Operation: An Operation represents work being performed in the background. -// -// The index service manages Cloud Firestore indexes. -// -// Index creation is performed asynchronously. -// An Operation resource is created for each such asynchronous operation. -// The state of the operation (including any errors encountered) -// may be queried via the Operation resource. -// -// The Operations collection provides a record of actions performed for the -// specified Project (including any Operations in progress). Operations are not -// created directly but through calls on other collections or resources. -// -// An Operation that is done may be deleted so that it is no longer listed as -// part of the Operation collection. Operations are garbage collected after -// 30 days. By default, ListOperations will only return in progress and failed -// operations. To list completed operation, issue a ListOperations request with -// the filter `done: true`. -// -// Operations are created by service `FirestoreAdmin`, but are accessed via -// service `google.longrunning.Operations`. -service FirestoreAdmin { - option (google.api.default_host) = "firestore.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/datastore"; - - // Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] - // which may be used to track the status of the creation. The metadata for - // the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. - rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" - body: "index" - }; - option (google.api.method_signature) = "parent,index"; - option (google.longrunning.operation_info) = { - response_type: "Index" - metadata_type: "IndexOperationMetadata" - }; - } - - // Lists composite indexes. - rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a composite index. - rpc GetIndex(GetIndexRequest) returns (Index) { - option (google.api.http) = { - get: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a composite index. - rpc DeleteIndex(DeleteIndexRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets the metadata and configuration for a Field. - rpc GetField(GetFieldRequest) returns (Field) { - option (google.api.http) = { - get: "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a field configuration. Currently, field updates apply only to - // single field index configuration. However, calls to - // [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid - // changing any configuration that the caller isn't aware of. The field mask - // should be specified as: `{ paths: "index_config" }`. - // - // This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to - // track the status of the field update. The metadata for - // the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. - // - // To configure the default field settings for the database, use - // the special `Field` with resource name: - // `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - rpc UpdateField(UpdateFieldRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}" - body: "field" - }; - option (google.api.method_signature) = "field"; - option (google.longrunning.operation_info) = { - response_type: "Field" - metadata_type: "FieldOperationMetadata" - }; - } - - // Lists the field configuration and metadata for this database. - // - // Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields - // that have been explicitly overridden. To issue this query, call - // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to - // `indexConfig.usesAncestorConfig:false` . - rpc ListFields(ListFieldsRequest) returns (ListFieldsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" - }; - option (google.api.method_signature) = "parent"; - } - - // Exports a copy of all or a subset of documents from Google Cloud Firestore - // to another storage system, such as Google Cloud Storage. Recent updates to - // documents may not be reflected in the export. The export occurs in the - // background and its progress can be monitored and managed via the - // Operation resource that is created. The output of an export may only be - // used once the associated operation is done. If an export operation is - // cancelled before completion it may leave partial data behind in Google - // Cloud Storage. - // - // For more details on export behavior and output format, refer to: - // https://cloud.google.com/firestore/docs/manage-data/export-import - rpc ExportDocuments(ExportDocumentsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/databases/*}:exportDocuments" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "ExportDocumentsResponse" - metadata_type: "ExportDocumentsMetadata" - }; - } - - // Imports documents into Google Cloud Firestore. Existing documents with the - // same name are overwritten. The import occurs in the background and its - // progress can be monitored and managed via the Operation resource that is - // created. If an ImportDocuments operation is cancelled, it is possible - // that a subset of the data has already been imported to Cloud Firestore. - rpc ImportDocuments(ImportDocumentsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/databases/*}:importDocuments" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "ImportDocumentsMetadata" - }; - } - - // Gets information about a database. - rpc GetDatabase(GetDatabaseRequest) returns (Database) { - option (google.api.http) = { - get: "/v1/{name=projects/*/databases/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List all the databases in the project. - rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*}/databases" - }; - option (google.api.method_signature) = "parent"; - } - - // Updates a database. - rpc UpdateDatabase(UpdateDatabaseRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v1/{database.name=projects/*/databases/*}" - body: "database" - }; - option (google.api.method_signature) = "database,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Database" - metadata_type: "UpdateDatabaseMetadata" - }; - } -} - -// A request to list the Firestore Databases in all locations for a project. -message ListDatabasesRequest { - // Required. A parent name of the form - // `projects/{project_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "firestore.googleapis.com/Database" - } - ]; -} - -// The list of databases for a project. -message ListDatabasesResponse { - // The databases in the project. - repeated Database databases = 1; -} - -// The request for [FirestoreAdmin.GetDatabase][google.firestore.admin.v1.FirestoreAdmin.GetDatabase]. -message GetDatabaseRequest { - // Required. A name of the form - // `projects/{project_id}/databases/{database_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Database" - } - ]; -} - -// The request for [FirestoreAdmin.UpdateDatabase][google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase]. -message UpdateDatabaseRequest { - // Required. The database to update. - Database database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The list of fields to be updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Metadata related to the update database operation. -message UpdateDatabaseMetadata { - -} - -// The request for [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. -message CreateIndexRequest { - // Required. A parent name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/CollectionGroup" - } - ]; - - // Required. The composite index to create. - Index index = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. -message ListIndexesRequest { - // Required. A parent name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/CollectionGroup" - } - ]; - - // The filter to apply to list results. - string filter = 2; - - // The number of results to return. - int32 page_size = 3; - - // A page token, returned from a previous call to - // [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes], that may be used to get the next - // page of results. - string page_token = 4; -} - -// The response for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. -message ListIndexesResponse { - // The requested indexes. - repeated Index indexes = 1; - - // A page token that may be used to request another page of results. If blank, - // this is the last page. - string next_page_token = 2; -} - -// The request for [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex]. -message GetIndexRequest { - // Required. A name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Index" - } - ]; -} - -// The request for [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex]. -message DeleteIndexRequest { - // Required. A name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Index" - } - ]; -} - -// The request for [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. -message UpdateFieldRequest { - // Required. The field to be updated. - Field field = 1 [(google.api.field_behavior) = REQUIRED]; - - // A mask, relative to the field. If specified, only configuration specified - // by this field_mask will be updated in the field. - google.protobuf.FieldMask update_mask = 2; -} - -// The request for [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField]. -message GetFieldRequest { - // Required. A name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Field" - } - ]; -} - -// The request for [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. -message ListFieldsRequest { - // Required. A parent name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/CollectionGroup" - } - ]; - - // The filter to apply to list results. Currently, - // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields - // that have been explicitly overridden. To issue this query, call - // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with a filter that includes - // `indexConfig.usesAncestorConfig:false` . - string filter = 2; - - // The number of results to return. - int32 page_size = 3; - - // A page token, returned from a previous call to - // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields], that may be used to get the next - // page of results. - string page_token = 4; -} - -// The response for [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. -message ListFieldsResponse { - // The requested fields. - repeated Field fields = 1; - - // A page token that may be used to request another page of results. If blank, - // this is the last page. - string next_page_token = 2; -} - -// The request for [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. -message ExportDocumentsRequest { - // Required. Database to export. Should be of the form: - // `projects/{project_id}/databases/{database_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Database" - } - ]; - - // Which collection ids to export. Unspecified means all collections. - repeated string collection_ids = 2; - - // The output URI. Currently only supports Google Cloud Storage URIs of the - // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name - // of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional - // Google Cloud Storage namespace path. When - // choosing a name, be sure to consider Google Cloud Storage naming - // guidelines: https://cloud.google.com/storage/docs/naming. - // If the URI is a bucket (without a namespace path), a prefix will be - // generated based on the start time. - string output_uri_prefix = 3; -} - -// The request for [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. -message ImportDocumentsRequest { - // Required. Database to import into. Should be of the form: - // `projects/{project_id}/databases/{database_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "firestore.googleapis.com/Database" - } - ]; - - // Which collection ids to import. Unspecified means all collections included - // in the import. - repeated string collection_ids = 2; - - // Location of the exported files. - // This must match the output_uri_prefix of an ExportDocumentsResponse from - // an export that has completed successfully. - // See: - // [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. - string input_uri_prefix = 3; -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto deleted file mode 100644 index 7e330a99c..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -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"; -option java_multiple_files = true; -option java_outer_classname = "IndexProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; - -// Cloud Firestore indexes enable simple and complex queries against -// documents in a database. -message Index { - option (google.api.resource) = { - type: "firestore.googleapis.com/Index" - pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" - }; - - // A field in an index. - // The field_path describes which field is indexed, the value_mode describes - // how the field value is indexed. - message IndexField { - // The supported orderings. - enum Order { - // The ordering is unspecified. Not a valid option. - ORDER_UNSPECIFIED = 0; - - // The field is ordered by ascending field value. - ASCENDING = 1; - - // The field is ordered by descending field value. - DESCENDING = 2; - } - - // The supported array value configurations. - enum ArrayConfig { - // The index does not support additional array queries. - ARRAY_CONFIG_UNSPECIFIED = 0; - - // The index supports array containment queries. - CONTAINS = 1; - } - - // Can be __name__. - // For single field indexes, this must match the name of the field or may - // be omitted. - string field_path = 1; - - // How the field value is indexed. - oneof value_mode { - // Indicates that this field supports ordering by the specified order or - // comparing using =, !=, <, <=, >, >=. - Order order = 2; - - // Indicates that this field supports operations on `array_value`s. - ArrayConfig array_config = 3; - } - } - - // 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 - // will transition to the `NEEDS_REPAIR` state. - enum State { - // The state is unspecified. - STATE_UNSPECIFIED = 0; - - // The index is being created. - // There is an active long-running operation for the index. - // The index is updated when writing a document. - // Some index data may exist. - CREATING = 1; - - // The index is ready to be used. - // The index is updated when writing a document. - // The index is fully populated from all stored documents it applies to. - READY = 2; - - // The index was being created, but something went wrong. - // There is no active long-running operation for the index, - // and the most recently finished long-running operation failed. - // The index is not updated when writing a document. - // Some index data may exist. - // Use the google.longrunning.Operations API to determine why the operation - // that last attempted to create this index failed, then re-create the - // index. - NEEDS_REPAIR = 3; - } - - // Output only. A server defined name for this index. - // The form of this name for composite indexes will be: - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` - // For single field indexes, this field will be empty. - string name = 1; - - // 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 same collection id. - // - // Indexes with a collection group query scope specified allow queries against - // all collections descended from a specific document, specified at query - // time, and that have the same collection id as this index. - QueryScope query_scope = 2; - - // The fields supported by this index. - // - // For composite indexes, this is always 2 or more fields. - // The last field entry is always for the field path `__name__`. If, on - // creation, `__name__` was not specified as the last field, it will be added - // automatically with the same direction as that of the last field defined. If - // the final field in a composite index is not directional, the `__name__` - // will be ordered ASCENDING (unless explicitly specified). - // - // For single field indexes, this will always be exactly one entry with a - // field path equal to the field path of the associated field. - repeated IndexField fields = 3; - - // Output only. The serving state of the index. - State state = 4; -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto deleted file mode 100644 index ce34de36b..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -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; -option java_outer_classname = "LocationProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; - -// The metadata message for [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata]. -message LocationMetadata { - -} diff --git a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto deleted file mode 100644 index 1b918fdb1..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -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"; -option java_multiple_files = true; -option java_outer_classname = "OperationProto"; -option java_package = "com.google.firestore.admin.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Firestore::Admin::V1"; - -// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from -// [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. -message IndexOperationMetadata { - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // The time this operation completed. Will be unset if operation still in - // progress. - google.protobuf.Timestamp end_time = 2; - - // The index resource that this operation is acting on. For example: - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - string index = 3; - - // The state of the operation. - OperationState state = 4; - - // The progress, in documents, of this operation. - Progress progress_documents = 5; - - // The progress, in bytes, of this operation. - Progress progress_bytes = 6; -} - -// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from -// [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. -message FieldOperationMetadata { - // Information about an index configuration change. - message IndexConfigDelta { - // Specifies how the index is changing. - enum ChangeType { - // The type of change is not specified or known. - CHANGE_TYPE_UNSPECIFIED = 0; - - // The single field index is being added. - ADD = 1; - - // The single field index is being removed. - REMOVE = 2; - } - - // Specifies how the index is changing. - ChangeType change_type = 1; - - // The index being changed. - Index index = 2; - } - - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // The time this operation completed. Will be unset if operation still in - // progress. - google.protobuf.Timestamp end_time = 2; - - // The field resource that this operation is acting on. For example: - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` - string field = 3; - - // A list of [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta], which describe the intent of this - // operation. - repeated IndexConfigDelta index_config_deltas = 4; - - // The state of the operation. - OperationState state = 5; - - // The progress, in documents, of this operation. - Progress progress_documents = 6; - - // The progress, in bytes, of this operation. - Progress progress_bytes = 7; -} - -// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from -// [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. -message ExportDocumentsMetadata { - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // The time this operation completed. Will be unset if operation still in - // progress. - google.protobuf.Timestamp end_time = 2; - - // The state of the export operation. - OperationState operation_state = 3; - - // The progress, in documents, of this operation. - Progress progress_documents = 4; - - // The progress, in bytes, of this operation. - Progress progress_bytes = 5; - - // Which collection ids are being exported. - repeated string collection_ids = 6; - - // Where the entities are being exported to. - string output_uri_prefix = 7; -} - -// Metadata for [google.longrunning.Operation][google.longrunning.Operation] results from -// [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. -message ImportDocumentsMetadata { - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // The time this operation completed. Will be unset if operation still in - // progress. - google.protobuf.Timestamp end_time = 2; - - // The state of the import operation. - OperationState operation_state = 3; - - // The progress, in documents, of this operation. - Progress progress_documents = 4; - - // The progress, in bytes, of this operation. - Progress progress_bytes = 5; - - // Which collection ids are being imported. - repeated string collection_ids = 6; - - // The location of the documents being imported. - string input_uri_prefix = 7; -} - -// Returned in the [google.longrunning.Operation][google.longrunning.Operation] response field. -message ExportDocumentsResponse { - // Location of the output files. This can be used to begin an import - // into Cloud Firestore (this project or another project) after the operation - // completes successfully. - string output_uri_prefix = 1; -} - -// Describes the state of the operation. -enum OperationState { - // Unspecified. - OPERATION_STATE_UNSPECIFIED = 0; - - // Request is being prepared for processing. - INITIALIZING = 1; - - // Request is actively being processed. - PROCESSING = 2; - - // Request is in the process of being cancelled after user called - // google.longrunning.Operations.CancelOperation on the operation. - CANCELLING = 3; - - // Request has been processed and is in its finalization stage. - FINALIZING = 4; - - // Request has completed successfully. - SUCCESSFUL = 5; - - // Request has finished being processed, but encountered an error. - FAILED = 6; - - // Request has finished being cancelled after user called - // google.longrunning.Operations.CancelOperation. - CANCELLED = 7; -} - -// Describes the progress of the operation. -// Unit of work is generic and must be interpreted based on where [Progress][google.firestore.admin.v1.Progress] -// is used. -message Progress { - // The amount of work estimated. - int64 estimated_work = 1; - - // The amount of work completed. - int64 completed_work = 2; -} diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js deleted file mode 100644 index 1ccd828d2..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js +++ /dev/null @@ -1,65 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, index) { - // [START firestore_v1_generated_FirestoreAdmin_CreateIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - */ - // const parent = 'abc123' - /** - * Required. The composite index to create. - */ - // const index = {} - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callCreateIndex() { - // Construct request - const request = { - parent, - index, - }; - - // Run request - const [operation] = await adminClient.createIndex(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateIndex(); - // [END firestore_v1_generated_FirestoreAdmin_CreateIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js deleted file mode 100644 index 2002ee5fa..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_DeleteIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - */ - // const name = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callDeleteIndex() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await adminClient.deleteIndex(request); - console.log(response); - } - - callDeleteIndex(); - // [END firestore_v1_generated_FirestoreAdmin_DeleteIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js deleted file mode 100644 index 784a6eb74..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js +++ /dev/null @@ -1,75 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_ExportDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Database to export. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - */ - // const name = 'abc123' - /** - * Which collection ids to export. Unspecified means all collections. - */ - // const collectionIds = 'abc123' - /** - * The output URI. Currently only supports Google Cloud Storage URIs of the - * form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the name - * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional - * Google Cloud Storage namespace path. When - * choosing a name, be sure to consider Google Cloud Storage naming - * guidelines: https://cloud.google.com/storage/docs/naming. - * If the URI is a bucket (without a namespace path), a prefix will be - * generated based on the start time. - */ - // const outputUriPrefix = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callExportDocuments() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await adminClient.exportDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callExportDocuments(); - // [END firestore_v1_generated_FirestoreAdmin_ExportDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js deleted file mode 100644 index a07ae055b..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_GetDatabase_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}` - */ - // const name = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callGetDatabase() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await adminClient.getDatabase(request); - console.log(response); - } - - callGetDatabase(); - // [END firestore_v1_generated_FirestoreAdmin_GetDatabase_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js deleted file mode 100644 index 00f78dd3c..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_GetField_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - */ - // const name = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callGetField() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await adminClient.getField(request); - console.log(response); - } - - callGetField(); - // [END firestore_v1_generated_FirestoreAdmin_GetField_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js deleted file mode 100644 index 792356c35..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_GetIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - */ - // const name = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callGetIndex() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await adminClient.getIndex(request); - console.log(response); - } - - callGetIndex(); - // [END firestore_v1_generated_FirestoreAdmin_GetIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js deleted file mode 100644 index 1135c861e..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js +++ /dev/null @@ -1,73 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_FirestoreAdmin_ImportDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Database to import into. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - */ - // const name = 'abc123' - /** - * Which collection ids to import. Unspecified means all collections included - * in the import. - */ - // const collectionIds = 'abc123' - /** - * Location of the exported files. - * This must match the output_uri_prefix of an ExportDocumentsResponse from - * an export that has completed successfully. - * See: - * google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix. - */ - // const inputUriPrefix = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callImportDocuments() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await adminClient.importDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportDocuments(); - // [END firestore_v1_generated_FirestoreAdmin_ImportDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js deleted file mode 100644 index e5fada31b..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_FirestoreAdmin_ListDatabases_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}` - */ - // const parent = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callListDatabases() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await adminClient.listDatabases(request); - console.log(response); - } - - callListDatabases(); - // [END firestore_v1_generated_FirestoreAdmin_ListDatabases_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js deleted file mode 100644 index b7814b88d..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js +++ /dev/null @@ -1,79 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_FirestoreAdmin_ListFields_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - */ - // const parent = 'abc123' - /** - * The filter to apply to list results. Currently, - * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields only supports listing fields - * that have been explicitly overridden. To issue this query, call - * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields with a filter that includes - * `indexConfig.usesAncestorConfig:false` . - */ - // const filter = 'abc123' - /** - * The number of results to return. - */ - // const pageSize = 1234 - /** - * A page token, returned from a previous call to - * FirestoreAdmin.ListFields google.firestore.admin.v1.FirestoreAdmin.ListFields, that may be used to get the next - * page of results. - */ - // const pageToken = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callListFields() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await adminClient.listFieldsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListFields(); - // [END firestore_v1_generated_FirestoreAdmin_ListFields_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js deleted file mode 100644 index 460f77d79..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js +++ /dev/null @@ -1,75 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_FirestoreAdmin_ListIndexes_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - */ - // const parent = 'abc123' - /** - * The filter to apply to list results. - */ - // const filter = 'abc123' - /** - * The number of results to return. - */ - // const pageSize = 1234 - /** - * A page token, returned from a previous call to - * FirestoreAdmin.ListIndexes google.firestore.admin.v1.FirestoreAdmin.ListIndexes, that may be used to get the next - * page of results. - */ - // const pageToken = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callListIndexes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await adminClient.listIndexesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListIndexes(); - // [END firestore_v1_generated_FirestoreAdmin_ListIndexes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js deleted file mode 100644 index c83a53088..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js +++ /dev/null @@ -1,63 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database to update. - */ - // const database = {} - /** - * The list of fields to be updated. - */ - // const updateMask = {} - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callUpdateDatabase() { - // Construct request - const request = { - database, - }; - - // Run request - const [operation] = await adminClient.updateDatabase(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateDatabase(); - // [END firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js deleted file mode 100644 index 65eaa42d5..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(field) { - // [START firestore_v1_generated_FirestoreAdmin_UpdateField_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The field to be updated. - */ - // const field = {} - /** - * A mask, relative to the field. If specified, only configuration specified - * by this field_mask will be updated in the field. - */ - // const updateMask = {} - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callUpdateField() { - // Construct request - const request = { - field, - }; - - // Run request - const [operation] = await adminClient.updateField(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateField(); - // [END firestore_v1_generated_FirestoreAdmin_UpdateField_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json deleted file mode 100644 index 9ecd3a140..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.firestore.admin.v1.json +++ /dev/null @@ -1,547 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-admin", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.firestore.admin.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_CreateIndex_async", - "title": "FirestoreAdmin createIndex Sample", - "origin": "API_DEFINITION", - "description": " Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the creation. The metadata for the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].", - "canonical": true, - "file": "firestore_admin.create_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateIndex", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "index", - "type": ".google.firestore.admin.v1.Index" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "CreateIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateIndex", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_ListIndexes_async", - "title": "FirestoreAdmin listIndexes Sample", - "origin": "API_DEFINITION", - "description": " Lists composite indexes.", - "canonical": true, - "file": "firestore_admin.list_indexes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListIndexes", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListIndexes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.ListIndexesResponse", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "ListIndexes", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListIndexes", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_GetIndex_async", - "title": "FirestoreAdmin getIndex Sample", - "origin": "API_DEFINITION", - "description": " Gets a composite index.", - "canonical": true, - "file": "firestore_admin.get_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetIndex", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.Index", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "GetIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetIndex", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_DeleteIndex_async", - "title": "FirestoreAdmin deleteIndex Sample", - "origin": "API_DEFINITION", - "description": " Deletes a composite index.", - "canonical": true, - "file": "firestore_admin.delete_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.DeleteIndex", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "DeleteIndex", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.DeleteIndex", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_GetField_async", - "title": "FirestoreAdmin getField Sample", - "origin": "API_DEFINITION", - "description": " Gets the metadata and configuration for a Field.", - "canonical": true, - "file": "firestore_admin.get_field.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetField", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetField", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.Field", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "GetField", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetField", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_UpdateField_async", - "title": "FirestoreAdmin updateField Sample", - "origin": "API_DEFINITION", - "description": " Updates a field configuration. Currently, field updates apply only to single field index configuration. However, calls to [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField] should provide a field mask to avoid changing any configuration that the caller isn't aware of. The field mask should be specified as: `{ paths: \"index_config\" }`. This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the field update. The metadata for the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata]. To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.", - "canonical": true, - "file": "firestore_admin.update_field.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateField", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateField", - "async": true, - "parameters": [ - { - "name": "field", - "type": ".google.firestore.admin.v1.Field" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "UpdateField", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateField", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_ListFields_async", - "title": "FirestoreAdmin listFields Sample", - "origin": "API_DEFINITION", - "description": " Lists the field configuration and metadata for this database. Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false` .", - "canonical": true, - "file": "firestore_admin.list_fields.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListFields", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListFields", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.ListFieldsResponse", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "ListFields", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListFields", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_ExportDocuments_async", - "title": "FirestoreAdmin exportDocuments Sample", - "origin": "API_DEFINITION", - "description": " Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage system, such as Google Cloud Storage. Recent updates to documents may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import", - "canonical": true, - "file": "firestore_admin.export_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExportDocuments", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ExportDocuments", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "collection_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "output_uri_prefix", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "ExportDocuments", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ExportDocuments", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_ImportDocuments_async", - "title": "FirestoreAdmin importDocuments Sample", - "origin": "API_DEFINITION", - "description": " Imports documents into Google Cloud Firestore. Existing documents with the same name are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.", - "canonical": true, - "file": "firestore_admin.import_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportDocuments", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ImportDocuments", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "collection_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "input_uri_prefix", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "ImportDocuments", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ImportDocuments", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_GetDatabase_async", - "title": "FirestoreAdmin getDatabase Sample", - "origin": "API_DEFINITION", - "description": " Gets information about a database.", - "canonical": true, - "file": "firestore_admin.get_database.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetDatabase", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.Database", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "GetDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.GetDatabase", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_ListDatabases_async", - "title": "FirestoreAdmin listDatabases Sample", - "origin": "API_DEFINITION", - "description": " List all the databases in the project.", - "canonical": true, - "file": "firestore_admin.list_databases.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDatabases", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListDatabases", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.admin.v1.ListDatabasesResponse", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "ListDatabases", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.ListDatabases", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async", - "title": "FirestoreAdmin updateDatabase Sample", - "origin": "API_DEFINITION", - "description": " Updates a database.", - "canonical": true, - "file": "firestore_admin.update_database.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase", - "async": true, - "parameters": [ - { - "name": "database", - "type": ".google.firestore.admin.v1.Database" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "UpdateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase", - "service": { - "shortName": "FirestoreAdmin", - "fullName": "google.firestore.admin.v1.FirestoreAdmin" - } - } - } - } - ] -} diff --git a/owl-bot-staging/admin/v1/src/index.ts b/owl-bot-staging/admin/v1/src/index.ts deleted file mode 100644 index d5c1e4e93..000000000 --- a/owl-bot-staging/admin/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const FirestoreAdminClient = v1.FirestoreAdminClient; -type FirestoreAdminClient = v1.FirestoreAdminClient; -export {v1, FirestoreAdminClient}; -export default {v1, FirestoreAdminClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts deleted file mode 100644 index 62d7cfbbd..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts +++ /dev/null @@ -1,1914 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/firestore_admin_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './firestore_admin_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * The Cloud Firestore Admin API. - * - * This API provides several administrative services for Cloud Firestore. - * - * Project, Database, Namespace, Collection, Collection Group, and Document are - * used as defined in the Google Cloud Firestore API. - * - * Operation: An Operation represents work being performed in the background. - * - * The index service manages Cloud Firestore indexes. - * - * Index creation is performed asynchronously. - * An Operation resource is created for each such asynchronous operation. - * The state of the operation (including any errors encountered) - * may be queried via the Operation resource. - * - * The Operations collection provides a record of actions performed for the - * specified Project (including any Operations in progress). Operations are not - * created directly but through calls on other collections or resources. - * - * An Operation that is done may be deleted so that it is no longer listed as - * part of the Operation collection. Operations are garbage collected after - * 30 days. By default, ListOperations will only return in progress and failed - * operations. To list completed operation, issue a ListOperations request with - * the filter `done: true`. - * - * Operations are created by service `FirestoreAdmin`, but are accessed via - * service `google.longrunning.Operations`. - * @class - * @memberof v1 - */ -export class FirestoreAdminClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - firestoreAdminStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FirestoreAdminClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof FirestoreAdminClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - collectionGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection}' - ), - databasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/databases/{database}' - ), - fieldPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}' - ), - indexPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listIndexes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes'), - listFields: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'fields') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const createIndexResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.Index') as gax.protobuf.Type; - const createIndexMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; - const updateFieldResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.Field') as gax.protobuf.Type; - const updateFieldMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.FieldOperationMetadata') as gax.protobuf.Type; - const exportDocumentsResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.ExportDocumentsResponse') as gax.protobuf.Type; - const exportDocumentsMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.ExportDocumentsMetadata') as gax.protobuf.Type; - const importDocumentsResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const importDocumentsMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.ImportDocumentsMetadata') as gax.protobuf.Type; - const updateDatabaseResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.Database') as gax.protobuf.Type; - const updateDatabaseMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.UpdateDatabaseMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createIndex: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createIndexResponse.decode.bind(createIndexResponse), - createIndexMetadata.decode.bind(createIndexMetadata)), - updateField: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateFieldResponse.decode.bind(updateFieldResponse), - updateFieldMetadata.decode.bind(updateFieldMetadata)), - exportDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - exportDocumentsResponse.decode.bind(exportDocumentsResponse), - exportDocumentsMetadata.decode.bind(exportDocumentsMetadata)), - importDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importDocumentsResponse.decode.bind(importDocumentsResponse), - importDocumentsMetadata.decode.bind(importDocumentsMetadata)), - updateDatabase: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateDatabaseResponse.decode.bind(updateDatabaseResponse), - updateDatabaseMetadata.decode.bind(updateDatabaseMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.firestore.admin.v1.FirestoreAdmin', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.firestoreAdminStub) { - return this.firestoreAdminStub; - } - - // Put together the "service stub" for - // google.firestore.admin.v1.FirestoreAdmin. - this.firestoreAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.firestore.admin.v1.FirestoreAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.firestore.admin.v1.FirestoreAdmin, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreAdminStubMethods = - ['createIndex', 'listIndexes', 'getIndex', 'deleteIndex', 'getField', 'updateField', 'listFields', 'exportDocuments', 'importDocuments', 'getDatabase', 'listDatabases', 'updateDatabase']; - for (const methodName of firestoreAdminStubMethods) { - const callPromise = this.firestoreAdminStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.firestoreAdminStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a composite index. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Index]{@link google.firestore.admin.v1.Index}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.get_index.js - * region_tag:firestore_v1_generated_FirestoreAdmin_GetIndex_async - */ - getIndex( - request?: protos.google.firestore.admin.v1.IGetIndexRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|undefined, {}|undefined - ]>; - getIndex( - request: protos.google.firestore.admin.v1.IGetIndexRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): void; - getIndex( - request: protos.google.firestore.admin.v1.IGetIndexRequest, - callback: Callback< - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): void; - getIndex( - request?: protos.google.firestore.admin.v1.IGetIndexRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.admin.v1.IIndex, - protos.google.firestore.admin.v1.IGetIndexRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getIndex(request, options, callback); - } -/** - * Deletes a composite index. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.delete_index.js - * region_tag:firestore_v1_generated_FirestoreAdmin_DeleteIndex_async - */ - deleteIndex( - request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|undefined, {}|undefined - ]>; - deleteIndex( - request: protos.google.firestore.admin.v1.IDeleteIndexRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, - {}|null|undefined>): void; - deleteIndex( - request: protos.google.firestore.admin.v1.IDeleteIndexRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, - {}|null|undefined>): void; - deleteIndex( - request?: protos.google.firestore.admin.v1.IDeleteIndexRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.admin.v1.IDeleteIndexRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteIndex(request, options, callback); - } -/** - * Gets the metadata and configuration for a Field. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Field]{@link google.firestore.admin.v1.Field}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.get_field.js - * region_tag:firestore_v1_generated_FirestoreAdmin_GetField_async - */ - getField( - request?: protos.google.firestore.admin.v1.IGetFieldRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|undefined, {}|undefined - ]>; - getField( - request: protos.google.firestore.admin.v1.IGetFieldRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, - {}|null|undefined>): void; - getField( - request: protos.google.firestore.admin.v1.IGetFieldRequest, - callback: Callback< - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, - {}|null|undefined>): void; - getField( - request?: protos.google.firestore.admin.v1.IGetFieldRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.admin.v1.IField, - protos.google.firestore.admin.v1.IGetFieldRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getField(request, options, callback); - } -/** - * Gets information about a database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A name of the form - * `projects/{project_id}/databases/{database_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Database]{@link google.firestore.admin.v1.Database}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.get_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_GetDatabase_async - */ - getDatabase( - request?: protos.google.firestore.admin.v1.IGetDatabaseRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|undefined, {}|undefined - ]>; - getDatabase( - request: protos.google.firestore.admin.v1.IGetDatabaseRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; - getDatabase( - request: protos.google.firestore.admin.v1.IGetDatabaseRequest, - callback: Callback< - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): void; - getDatabase( - request?: protos.google.firestore.admin.v1.IGetDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.admin.v1.IDatabase, - protos.google.firestore.admin.v1.IGetDatabaseRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getDatabase(request, options, callback); - } -/** - * List all the databases in the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListDatabasesResponse]{@link google.firestore.admin.v1.ListDatabasesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.list_databases.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ListDatabases_async - */ - listDatabases( - request?: protos.google.firestore.admin.v1.IListDatabasesRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|undefined, {}|undefined - ]>; - listDatabases( - request: protos.google.firestore.admin.v1.IListDatabasesRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, - {}|null|undefined>): void; - listDatabases( - request: protos.google.firestore.admin.v1.IListDatabasesRequest, - callback: Callback< - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, - {}|null|undefined>): void; - listDatabases( - request?: protos.google.firestore.admin.v1.IListDatabasesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.admin.v1.IListDatabasesResponse, - protos.google.firestore.admin.v1.IListDatabasesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listDatabases(request, options, callback); - } - -/** - * Creates a composite index. This returns a {@link google.longrunning.Operation|google.longrunning.Operation} - * which may be used to track the status of the creation. The metadata for - * the operation will be the type {@link google.firestore.admin.v1.IndexOperationMetadata|IndexOperationMetadata}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {google.firestore.admin.v1.Index} request.index - * Required. The composite index to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_index.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateIndex_async - */ - createIndex( - request?: protos.google.firestore.admin.v1.ICreateIndexRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createIndex( - request: protos.google.firestore.admin.v1.ICreateIndexRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createIndex( - request: protos.google.firestore.admin.v1.ICreateIndexRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createIndex( - request?: protos.google.firestore.admin.v1.ICreateIndexRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createIndex(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createIndex()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_index.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateIndex_async - */ - async checkCreateIndexProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a field configuration. Currently, field updates apply only to - * single field index configuration. However, calls to - * {@link google.firestore.admin.v1.FirestoreAdmin.UpdateField|FirestoreAdmin.UpdateField} should provide a field mask to avoid - * changing any configuration that the caller isn't aware of. The field mask - * should be specified as: `{ paths: "index_config" }`. - * - * This call returns a {@link google.longrunning.Operation|google.longrunning.Operation} which may be used to - * track the status of the field update. The metadata for - * the operation will be the type {@link google.firestore.admin.v1.FieldOperationMetadata|FieldOperationMetadata}. - * - * To configure the default field settings for the database, use - * the special `Field` with resource name: - * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.firestore.admin.v1.Field} request.field - * Required. The field to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask, relative to the field. If specified, only configuration specified - * by this field_mask will be updated in the field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.update_field.js - * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateField_async - */ - updateField( - request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateField( - request: protos.google.firestore.admin.v1.IUpdateFieldRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateField( - request: protos.google.firestore.admin.v1.IUpdateFieldRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateField( - request?: protos.google.firestore.admin.v1.IUpdateFieldRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'field.name': request.field!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateField(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateField()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.update_field.js - * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateField_async - */ - async checkUpdateFieldProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateField, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Exports a copy of all or a subset of documents from Google Cloud Firestore - * to another storage system, such as Google Cloud Storage. Recent updates to - * documents may not be reflected in the export. The export occurs in the - * background and its progress can be monitored and managed via the - * Operation resource that is created. The output of an export may only be - * used once the associated operation is done. If an export operation is - * cancelled before completion it may leave partial data behind in Google - * Cloud Storage. - * - * For more details on export behavior and output format, refer to: - * https://cloud.google.com/firestore/docs/manage-data/export-import - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Database to export. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.collectionIds - * Which collection ids to export. Unspecified means all collections. - * @param {string} request.outputUriPrefix - * The output URI. Currently only supports Google Cloud Storage URIs of the - * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name - * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional - * Google Cloud Storage namespace path. When - * choosing a name, be sure to consider Google Cloud Storage naming - * guidelines: https://cloud.google.com/storage/docs/naming. - * If the URI is a bucket (without a namespace path), a prefix will be - * generated based on the start time. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.export_documents.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ExportDocuments_async - */ - exportDocuments( - request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - exportDocuments( - request: protos.google.firestore.admin.v1.IExportDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportDocuments( - request: protos.google.firestore.admin.v1.IExportDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportDocuments( - request?: protos.google.firestore.admin.v1.IExportDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.exportDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `exportDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.export_documents.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ExportDocuments_async - */ - async checkExportDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Imports documents into Google Cloud Firestore. Existing documents with the - * same name are overwritten. The import occurs in the background and its - * progress can be monitored and managed via the Operation resource that is - * created. If an ImportDocuments operation is cancelled, it is possible - * that a subset of the data has already been imported to Cloud Firestore. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Database to import into. Should be of the form: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.collectionIds - * Which collection ids to import. Unspecified means all collections included - * in the import. - * @param {string} request.inputUriPrefix - * Location of the exported files. - * This must match the output_uri_prefix of an ExportDocumentsResponse from - * an export that has completed successfully. - * See: - * {@link google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix|google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.import_documents.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ImportDocuments_async - */ - importDocuments( - request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importDocuments( - request: protos.google.firestore.admin.v1.IImportDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request: protos.google.firestore.admin.v1.IImportDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importDocuments( - request?: protos.google.firestore.admin.v1.IImportDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.importDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.import_documents.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ImportDocuments_async - */ - async checkImportDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a database. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.firestore.admin.v1.Database} request.database - * Required. The database to update. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.update_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async - */ - updateDatabase( - request?: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateDatabase( - request: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateDatabase( - request: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateDatabase( - request?: protos.google.firestore.admin.v1.IUpdateDatabaseRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database.name': request.database!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateDatabase(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateDatabase()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.update_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async - */ - async checkUpdateDatabaseProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateDatabase, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists composite indexes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Index]{@link google.firestore.admin.v1.Index}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listIndexesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listIndexes( - request?: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IIndex[], - protos.google.firestore.admin.v1.IListIndexesRequest|null, - protos.google.firestore.admin.v1.IListIndexesResponse - ]>; - listIndexes( - request: protos.google.firestore.admin.v1.IListIndexesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.admin.v1.IListIndexesRequest, - protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.firestore.admin.v1.IIndex>): void; - listIndexes( - request: protos.google.firestore.admin.v1.IListIndexesRequest, - callback: PaginationCallback< - protos.google.firestore.admin.v1.IListIndexesRequest, - protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.firestore.admin.v1.IIndex>): void; - listIndexes( - request?: protos.google.firestore.admin.v1.IListIndexesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.admin.v1.IListIndexesRequest, - protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.firestore.admin.v1.IIndex>, - callback?: PaginationCallback< - protos.google.firestore.admin.v1.IListIndexesRequest, - protos.google.firestore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.firestore.admin.v1.IIndex>): - Promise<[ - protos.google.firestore.admin.v1.IIndex[], - protos.google.firestore.admin.v1.IListIndexesRequest|null, - protos.google.firestore.admin.v1.IListIndexesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listIndexes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Index]{@link google.firestore.admin.v1.Index} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listIndexesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listIndexesStream( - request?: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listIndexes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listIndexes.createStream( - this.innerApiCalls.listIndexes as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listIndexes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Index]{@link google.firestore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.list_indexes.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ListIndexes_async - */ - listIndexesAsync( - request?: protos.google.firestore.admin.v1.IListIndexesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listIndexes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listIndexes.asyncIterate( - this.innerApiCalls['listIndexes'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Lists the field configuration and metadata for this database. - * - * Currently, {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields - * that have been explicitly overridden. To issue this query, call - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with the filter set to - * `indexConfig.usesAncestorConfig:false` . - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. Currently, - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields - * that have been explicitly overridden. To issue this query, call - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes - * `indexConfig.usesAncestorConfig:false` . - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Field]{@link google.firestore.admin.v1.Field}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFieldsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listFields( - request?: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.admin.v1.IField[], - protos.google.firestore.admin.v1.IListFieldsRequest|null, - protos.google.firestore.admin.v1.IListFieldsResponse - ]>; - listFields( - request: protos.google.firestore.admin.v1.IListFieldsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.admin.v1.IListFieldsRequest, - protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, - protos.google.firestore.admin.v1.IField>): void; - listFields( - request: protos.google.firestore.admin.v1.IListFieldsRequest, - callback: PaginationCallback< - protos.google.firestore.admin.v1.IListFieldsRequest, - protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, - protos.google.firestore.admin.v1.IField>): void; - listFields( - request?: protos.google.firestore.admin.v1.IListFieldsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.admin.v1.IListFieldsRequest, - protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, - protos.google.firestore.admin.v1.IField>, - callback?: PaginationCallback< - protos.google.firestore.admin.v1.IListFieldsRequest, - protos.google.firestore.admin.v1.IListFieldsResponse|null|undefined, - protos.google.firestore.admin.v1.IField>): - Promise<[ - protos.google.firestore.admin.v1.IField[], - protos.google.firestore.admin.v1.IListFieldsRequest|null, - protos.google.firestore.admin.v1.IListFieldsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listFields(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. Currently, - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields - * that have been explicitly overridden. To issue this query, call - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes - * `indexConfig.usesAncestorConfig:false` . - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Field]{@link google.firestore.admin.v1.Field} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFieldsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listFieldsStream( - request?: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listFields']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFields.createStream( - this.innerApiCalls.listFields as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listFields`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. A parent name of the form - * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` - * @param {string} request.filter - * The filter to apply to list results. Currently, - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields - * that have been explicitly overridden. To issue this query, call - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with a filter that includes - * `indexConfig.usesAncestorConfig:false` . - * @param {number} request.pageSize - * The number of results to return. - * @param {string} request.pageToken - * A page token, returned from a previous call to - * {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next - * page of results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Field]{@link google.firestore.admin.v1.Field}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.list_fields.js - * region_tag:firestore_v1_generated_FirestoreAdmin_ListFields_async - */ - listFieldsAsync( - request?: protos.google.firestore.admin.v1.IListFieldsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listFields']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFields.asyncIterate( - this.innerApiCalls['listFields'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified collectionGroup resource name string. - * - * @param {string} project - * @param {string} database - * @param {string} collection - * @returns {string} Resource name string. - */ - collectionGroupPath(project:string,database:string,collection:string) { - return this.pathTemplates.collectionGroupPathTemplate.render({ - project: project, - database: database, - collection: collection, - }); - } - - /** - * Parse the project from CollectionGroup resource. - * - * @param {string} collectionGroupName - * A fully-qualified path representing CollectionGroup resource. - * @returns {string} A string representing the project. - */ - matchProjectFromCollectionGroupName(collectionGroupName: string) { - return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).project; - } - - /** - * Parse the database from CollectionGroup resource. - * - * @param {string} collectionGroupName - * A fully-qualified path representing CollectionGroup resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromCollectionGroupName(collectionGroupName: string) { - return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).database; - } - - /** - * Parse the collection from CollectionGroup resource. - * - * @param {string} collectionGroupName - * A fully-qualified path representing CollectionGroup resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromCollectionGroupName(collectionGroupName: string) { - return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).collection; - } - - /** - * Return a fully-qualified database resource name string. - * - * @param {string} project - * @param {string} database - * @returns {string} Resource name string. - */ - databasePath(project:string,database:string) { - return this.pathTemplates.databasePathTemplate.render({ - project: project, - database: database, - }); - } - - /** - * Parse the project from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).project; - } - - /** - * Parse the database from Database resource. - * - * @param {string} databaseName - * A fully-qualified path representing Database resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromDatabaseName(databaseName: string) { - return this.pathTemplates.databasePathTemplate.match(databaseName).database; - } - - /** - * Return a fully-qualified field resource name string. - * - * @param {string} project - * @param {string} database - * @param {string} collection - * @param {string} field - * @returns {string} Resource name string. - */ - fieldPath(project:string,database:string,collection:string,field:string) { - return this.pathTemplates.fieldPathTemplate.render({ - project: project, - database: database, - collection: collection, - field: field, - }); - } - - /** - * Parse the project from Field resource. - * - * @param {string} fieldName - * A fully-qualified path representing Field resource. - * @returns {string} A string representing the project. - */ - matchProjectFromFieldName(fieldName: string) { - return this.pathTemplates.fieldPathTemplate.match(fieldName).project; - } - - /** - * Parse the database from Field resource. - * - * @param {string} fieldName - * A fully-qualified path representing Field resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromFieldName(fieldName: string) { - return this.pathTemplates.fieldPathTemplate.match(fieldName).database; - } - - /** - * Parse the collection from Field resource. - * - * @param {string} fieldName - * A fully-qualified path representing Field resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromFieldName(fieldName: string) { - return this.pathTemplates.fieldPathTemplate.match(fieldName).collection; - } - - /** - * Parse the field from Field resource. - * - * @param {string} fieldName - * A fully-qualified path representing Field resource. - * @returns {string} A string representing the field. - */ - matchFieldFromFieldName(fieldName: string) { - return this.pathTemplates.fieldPathTemplate.match(fieldName).field; - } - - /** - * Return a fully-qualified index resource name string. - * - * @param {string} project - * @param {string} database - * @param {string} collection - * @param {string} index - * @returns {string} Resource name string. - */ - indexPath(project:string,database:string,collection:string,index:string) { - return this.pathTemplates.indexPathTemplate.render({ - project: project, - database: database, - collection: collection, - index: index, - }); - } - - /** - * Parse the project from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the project. - */ - matchProjectFromIndexName(indexName: string) { - return this.pathTemplates.indexPathTemplate.match(indexName).project; - } - - /** - * Parse the database from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the database. - */ - matchDatabaseFromIndexName(indexName: string) { - return this.pathTemplates.indexPathTemplate.match(indexName).database; - } - - /** - * Parse the collection from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the collection. - */ - matchCollectionFromIndexName(indexName: string) { - return this.pathTemplates.indexPathTemplate.match(indexName).collection; - } - - /** - * Parse the index from Index resource. - * - * @param {string} indexName - * A fully-qualified path representing Index resource. - * @returns {string} A string representing the index. - */ - matchIndexFromIndexName(indexName: string) { - return this.pathTemplates.indexPathTemplate.match(indexName).index; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.firestoreAdminStub && !this._terminated) { - return this.firestoreAdminStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json deleted file mode 100644 index f2b58181b..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "interfaces": { - "google.firestore.admin.v1.FirestoreAdmin": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "deadline_exceeded_internal_unavailable": [ - "DEADLINE_EXCEEDED", - "INTERNAL", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateIndex": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListIndexes": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", - "retry_params_name": "default" - }, - "GetIndex": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", - "retry_params_name": "default" - }, - "DeleteIndex": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", - "retry_params_name": "default" - }, - "GetField": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", - "retry_params_name": "default" - }, - "UpdateField": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListFields": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_internal_unavailable", - "retry_params_name": "default" - }, - "ExportDocuments": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ImportDocuments": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDatabase": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListDatabases": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateDatabase": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json b/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json deleted file mode 100644 index 11c6963e5..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/firestore/admin/v1/database.proto", - "../../protos/google/firestore/admin/v1/field.proto", - "../../protos/google/firestore/admin/v1/firestore_admin.proto", - "../../protos/google/firestore/admin/v1/index.proto", - "../../protos/google/firestore/admin/v1/location.proto", - "../../protos/google/firestore/admin/v1/operation.proto" -] diff --git a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json deleted file mode 100644 index dd1e77d2a..000000000 --- a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.firestore.admin.v1", - "libraryPackage": "@google-cloud/firestore-admin", - "services": { - "FirestoreAdmin": { - "clients": { - "grpc": { - "libraryClient": "FirestoreAdminClient", - "rpcs": { - "GetIndex": { - "methods": [ - "getIndex" - ] - }, - "DeleteIndex": { - "methods": [ - "deleteIndex" - ] - }, - "GetField": { - "methods": [ - "getField" - ] - }, - "GetDatabase": { - "methods": [ - "getDatabase" - ] - }, - "ListDatabases": { - "methods": [ - "listDatabases" - ] - }, - "CreateIndex": { - "methods": [ - "createIndex" - ] - }, - "UpdateField": { - "methods": [ - "updateField" - ] - }, - "ExportDocuments": { - "methods": [ - "exportDocuments" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "UpdateDatabase": { - "methods": [ - "updateDatabase" - ] - }, - "ListIndexes": { - "methods": [ - "listIndexes", - "listIndexesStream", - "listIndexesAsync" - ] - }, - "ListFields": { - "methods": [ - "listFields", - "listFieldsStream", - "listFieldsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FirestoreAdminClient", - "rpcs": { - "GetIndex": { - "methods": [ - "getIndex" - ] - }, - "DeleteIndex": { - "methods": [ - "deleteIndex" - ] - }, - "GetField": { - "methods": [ - "getField" - ] - }, - "GetDatabase": { - "methods": [ - "getDatabase" - ] - }, - "ListDatabases": { - "methods": [ - "listDatabases" - ] - }, - "CreateIndex": { - "methods": [ - "createIndex" - ] - }, - "UpdateField": { - "methods": [ - "updateField" - ] - }, - "ExportDocuments": { - "methods": [ - "exportDocuments" - ] - }, - "ImportDocuments": { - "methods": [ - "importDocuments" - ] - }, - "UpdateDatabase": { - "methods": [ - "updateDatabase" - ] - }, - "ListIndexes": { - "methods": [ - "listIndexes", - "listIndexesStream", - "listIndexesAsync" - ] - }, - "ListFields": { - "methods": [ - "listFields", - "listFieldsStream", - "listFieldsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/index.ts b/owl-bot-staging/admin/v1/src/v1/index.ts deleted file mode 100644 index f837949da..000000000 --- a/owl-bot-staging/admin/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {FirestoreAdminClient} from './firestore_admin_client'; diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index b5b76cbeb..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const admin = require('@google-cloud/firestore-admin'); - -function main() { - const firestoreAdminClient = new admin.FirestoreAdminClient(); -} - -main(); diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index c663441b8..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {FirestoreAdminClient} from '@google-cloud/firestore-admin'; - -// check that the client class type name can be used -function doStuffWithFirestoreAdminClient(client: FirestoreAdminClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const firestoreAdminClient = new FirestoreAdminClient(); - doStuffWithFirestoreAdminClient(firestoreAdminClient); -} - -main(); diff --git a/owl-bot-staging/admin/v1/system-test/install.ts b/owl-bot-staging/admin/v1/system-test/install.ts deleted file mode 100644 index 8ec452229..000000000 --- a/owl-bot-staging/admin/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts b/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts deleted file mode 100644 index 201a1f317..000000000 --- a/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts +++ /dev/null @@ -1,2082 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as firestoreadminModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.FirestoreAdminClient', () => { - it('has servicePath', () => { - const servicePath = firestoreadminModule.v1.FirestoreAdminClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = firestoreadminModule.v1.FirestoreAdminClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = firestoreadminModule.v1.FirestoreAdminClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreAdminStub, undefined); - await client.initialize(); - assert(client.firestoreAdminStub); - }); - - it('has close method for the initialized client', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.firestoreAdminStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreAdminStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getIndex', () => { - it('invokes getIndex without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Index()); - client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); - const [response] = await client.getIndex(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIndex without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Index()); - client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIndex( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IIndex|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIndex with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIndex(request), expectedError); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIndex with closed client', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetIndexRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIndex(request), expectedError); - }); - }); - - describe('deleteIndex', () => { - it('invokes deleteIndex without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); - const [response] = await client.deleteIndex(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteIndex without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteIndex = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteIndex( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteIndex with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteIndex(request), expectedError); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteIndex with closed client', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.DeleteIndexRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteIndex(request), expectedError); - }); - }); - - describe('getField', () => { - it('invokes getField without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Field()); - client.innerApiCalls.getField = stubSimpleCall(expectedResponse); - const [response] = await client.getField(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getField as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getField without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Field()); - client.innerApiCalls.getField = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getField( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IField|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getField as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getField with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getField(request), expectedError); - assert((client.innerApiCalls.getField as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getField with closed client', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetFieldRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getField(request), expectedError); - }); - }); - - describe('getDatabase', () => { - it('invokes getDatabase without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Database()); - client.innerApiCalls.getDatabase = stubSimpleCall(expectedResponse); - const [response] = await client.getDatabase(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDatabase without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.Database()); - client.innerApiCalls.getDatabase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDatabase( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDatabase with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabase(request), expectedError); - assert((client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDatabase with closed client', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.GetDatabaseRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDatabase(request), expectedError); - }); - }); - - describe('listDatabases', () => { - it('invokes listDatabases without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesResponse()); - client.innerApiCalls.listDatabases = stubSimpleCall(expectedResponse); - const [response] = await client.listDatabases(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDatabases without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesResponse()); - client.innerApiCalls.listDatabases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatabases( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IListDatabasesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDatabases with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabases(request), expectedError); - assert((client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDatabases with closed client', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListDatabasesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listDatabases(request), expectedError); - }); - }); - - describe('createIndex', () => { - it('invokes createIndex without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); - const [operation] = await client.createIndex(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createIndex without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createIndex( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createIndex with call error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createIndex(request), expectedError); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createIndex with LRO error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.CreateIndexRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createIndex(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateIndexProgress without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateIndexProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateIndexProgress with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateIndexProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateField', () => { - it('invokes updateField without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); - request.field = {}; - request.field.name = ''; - const expectedHeaderRequestParams = "field.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateField = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateField(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateField as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateField without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); - request.field = {}; - request.field.name = ''; - const expectedHeaderRequestParams = "field.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateField = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateField( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateField as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateField with call error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); - request.field = {}; - request.field.name = ''; - const expectedHeaderRequestParams = "field.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateField(request), expectedError); - assert((client.innerApiCalls.updateField as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateField with LRO error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateFieldRequest()); - request.field = {}; - request.field.name = ''; - const expectedHeaderRequestParams = "field.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateField(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateField as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateFieldProgress without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFieldProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateFieldProgress with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFieldProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('exportDocuments', () => { - it('invokes exportDocuments without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.exportDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes exportDocuments without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.exportDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes exportDocuments with call error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportDocuments(request), expectedError); - assert((client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes exportDocuments with LRO error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ExportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkExportDocumentsProgress without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkExportDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkExportDocumentsProgress with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importDocuments', () => { - it('invokes importDocuments without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.importDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importDocuments without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importDocuments with call error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importDocuments(request), expectedError); - assert((client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importDocuments with LRO error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ImportDocumentsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportDocumentsProgress without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportDocumentsProgress with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateDatabase', () => { - it('invokes updateDatabase without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); - request.database = {}; - request.database.name = ''; - const expectedHeaderRequestParams = "database.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDatabase without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); - request.database = {}; - request.database.name = ''; - const expectedHeaderRequestParams = "database.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDatabase( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateDatabase with call error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); - request.database = {}; - request.database.name = ''; - const expectedHeaderRequestParams = "database.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDatabase(request), expectedError); - assert((client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDatabase with LRO error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.UpdateDatabaseRequest()); - request.database = {}; - request.database.name = ''; - const expectedHeaderRequestParams = "database.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDatabase(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateDatabaseProgress without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateDatabaseProgress with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateDatabaseProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listIndexes', () => { - it('invokes listIndexes without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - ]; - client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); - const [response] = await client.listIndexes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listIndexes without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - ]; - client.innerApiCalls.listIndexes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listIndexes( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IIndex[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listIndexes with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listIndexes(request), expectedError); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listIndexesStream without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - ]; - client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listIndexesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.admin.v1.Index[] = []; - stream.on('data', (response: protos.google.firestore.admin.v1.Index) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listIndexesStream with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listIndexesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.admin.v1.Index[] = []; - stream.on('data', (response: protos.google.firestore.admin.v1.Index) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listIndexes without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - generateSampleMessage(new protos.google.firestore.admin.v1.Index()), - ]; - client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.admin.v1.IIndex[] = []; - const iterable = client.listIndexesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listIndexes with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListIndexesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listIndexesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.admin.v1.IIndex[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listFields', () => { - it('invokes listFields without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - ]; - client.innerApiCalls.listFields = stubSimpleCall(expectedResponse); - const [response] = await client.listFields(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listFields as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listFields without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - ]; - client.innerApiCalls.listFields = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFields( - request, - (err?: Error|null, result?: protos.google.firestore.admin.v1.IField[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listFields as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listFields with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFields(request), expectedError); - assert((client.innerApiCalls.listFields as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listFieldsStream without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - ]; - client.descriptors.page.listFields.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFieldsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.admin.v1.Field[] = []; - stream.on('data', (response: protos.google.firestore.admin.v1.Field) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFields, request)); - assert.strictEqual( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listFieldsStream with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listFields.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFieldsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.admin.v1.Field[] = []; - stream.on('data', (response: protos.google.firestore.admin.v1.Field) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFields, request)); - assert.strictEqual( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listFields without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - generateSampleMessage(new protos.google.firestore.admin.v1.Field()), - ]; - client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.admin.v1.IField[] = []; - const iterable = client.listFieldsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listFields with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.admin.v1.ListFieldsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listFields.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFieldsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.admin.v1.IField[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('collectionGroup', () => { - const fakePath = "/rendered/path/collectionGroup"; - const expectedParameters = { - project: "projectValue", - database: "databaseValue", - collection: "collectionValue", - }; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.collectionGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.collectionGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('collectionGroupPath', () => { - const result = client.collectionGroupPath("projectValue", "databaseValue", "collectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.collectionGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCollectionGroupName', () => { - const result = client.matchProjectFromCollectionGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromCollectionGroupName', () => { - const result = client.matchDatabaseFromCollectionGroupName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromCollectionGroupName', () => { - const result = client.matchCollectionFromCollectionGroupName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.collectionGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('database', () => { - const fakePath = "/rendered/path/database"; - const expectedParameters = { - project: "projectValue", - database: "databaseValue", - }; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.databasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.databasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('databasePath', () => { - const result = client.databasePath("projectValue", "databaseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.databasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatabaseName', () => { - const result = client.matchProjectFromDatabaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromDatabaseName', () => { - const result = client.matchDatabaseFromDatabaseName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.databasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('field', () => { - const fakePath = "/rendered/path/field"; - const expectedParameters = { - project: "projectValue", - database: "databaseValue", - collection: "collectionValue", - field: "fieldValue", - }; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.fieldPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.fieldPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('fieldPath', () => { - const result = client.fieldPath("projectValue", "databaseValue", "collectionValue", "fieldValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.fieldPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFieldName', () => { - const result = client.matchProjectFromFieldName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromFieldName', () => { - const result = client.matchDatabaseFromFieldName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromFieldName', () => { - const result = client.matchCollectionFromFieldName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFieldFromFieldName', () => { - const result = client.matchFieldFromFieldName(fakePath); - assert.strictEqual(result, "fieldValue"); - assert((client.pathTemplates.fieldPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('index', () => { - const fakePath = "/rendered/path/index"; - const expectedParameters = { - project: "projectValue", - database: "databaseValue", - collection: "collectionValue", - index: "indexValue", - }; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.indexPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.indexPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('indexPath', () => { - const result = client.indexPath("projectValue", "databaseValue", "collectionValue", "indexValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.indexPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromIndexName', () => { - const result = client.matchProjectFromIndexName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.indexPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatabaseFromIndexName', () => { - const result = client.matchDatabaseFromIndexName(fakePath); - assert.strictEqual(result, "databaseValue"); - assert((client.pathTemplates.indexPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCollectionFromIndexName', () => { - const result = client.matchCollectionFromIndexName(fakePath); - assert.strictEqual(result, "collectionValue"); - assert((client.pathTemplates.indexPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchIndexFromIndexName', () => { - const result = client.matchIndexFromIndexName(fakePath); - assert.strictEqual(result, "indexValue"); - assert((client.pathTemplates.indexPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/admin/v1/tsconfig.json b/owl-bot-staging/admin/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/admin/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/admin/v1/webpack.config.js b/owl-bot-staging/admin/v1/webpack.config.js deleted file mode 100644 index 6eb32a37a..000000000 --- a/owl-bot-staging/admin/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'FirestoreAdmin', - filename: './firestore-admin.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index b88273f36..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/firestore', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b0..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e14786..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 02057e6ac..000000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Firestore: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 7719fd82b..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/firestore", - "version": "0.1.0", - "description": "Firestore client for Node.js", - "repository": "googleapis/nodejs-firestore", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google firestore", - "firestore", - "firestore" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/common.proto b/owl-bot-staging/v1/protos/google/firestore/v1/common.proto deleted file mode 100644 index 588a9b81b..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/common.proto +++ /dev/null @@ -1,82 +0,0 @@ -// 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1; - -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.firestore.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1"; -option ruby_package = "Google::Cloud::Firestore::V1"; - -// A set of field paths on a document. -// Used to restrict a get or update operation on a document to a subset of its -// fields. -// This is different from standard field masks, as this is always scoped to a -// [Document][google.firestore.v1.Document], and takes in account the dynamic nature of [Value][google.firestore.v1.Value]. -message DocumentMask { - // The list of field paths in the mask. See [Document.fields][google.firestore.v1.Document.fields] for a field - // path syntax reference. - repeated string field_paths = 1; -} - -// A precondition on a document, used for conditional operations. -message Precondition { - // The type of precondition. - oneof condition_type { - // When set to `true`, the target document must exist. - // When set to `false`, the target document must not exist. - bool exists = 1; - - // When set, the target document must exist and have been last updated at - // that time. Timestamp must be microsecond aligned. - google.protobuf.Timestamp update_time = 2; - } -} - -// Options for creating a new transaction. -message TransactionOptions { - // Options for a transaction that can be used to read and write documents. - message ReadWrite { - // An optional transaction to retry. - bytes retry_transaction = 1; - } - - // Options for a transaction that can only be used to read documents. - message ReadOnly { - // The consistency mode for this transaction. If not set, defaults to strong - // consistency. - oneof consistency_selector { - // Reads documents at the given time. - // This may not be older than 60 seconds. - google.protobuf.Timestamp read_time = 2; - } - } - - // The mode of the transaction. - oneof mode { - // The transaction can only be used for read operations. - ReadOnly read_only = 2; - - // The transaction can be used for both read and write operations. - ReadWrite read_write = 3; - } -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/document.proto b/owl-bot-staging/v1/protos/google/firestore/v1/document.proto deleted file mode 100644 index 41283588e..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/document.proto +++ /dev/null @@ -1,149 +0,0 @@ -// 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1; - -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/latlng.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.firestore.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1"; -option ruby_package = "Google::Cloud::Firestore::V1"; - -// A Firestore document. -// -// Must not exceed 1 MiB - 4 bytes. -message Document { - // The resource name of the document, for example - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; - - // The document's fields. - // - // The map keys represent field names. - // - // A simple field name contains only characters `a` to `z`, `A` to `Z`, - // `0` to `9`, or `_`, and must not start with `0` to `9`. For example, - // `foo_bar_17`. - // - // Field names matching the regular expression `__.*__` are reserved. Reserved - // field names are forbidden except in certain documented contexts. The map - // keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be - // empty. - // - // Field paths may be used in other contexts to refer to structured fields - // defined here. For `map_value`, the field path is represented by the simple - // or quoted field names of the containing fields, delimited by `.`. For - // example, the structured field - // `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be - // represented by the field path `foo.x&y`. - // - // Within a field path, a quoted field name starts and ends with `` ` `` and - // may contain any character. Some characters, including `` ` ``, must be - // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and - // `` `bak\`tik` `` represents `` bak`tik ``. - map fields = 2; - - // Output only. The time at which the document was created. - // - // This value increases monotonically when a document is deleted then - // recreated. It can also be compared to values from other documents and - // the `read_time` of a query. - google.protobuf.Timestamp create_time = 3; - - // Output only. The time at which the document was last changed. - // - // This value is initially set to the `create_time` then increases - // monotonically with each change to the document. It can also be - // compared to values from other documents and the `read_time` of a query. - google.protobuf.Timestamp update_time = 4; -} - -// A message that can hold any of the supported value types. -message Value { - // Must have a value set. - oneof value_type { - // A null value. - google.protobuf.NullValue null_value = 11; - - // A boolean value. - bool boolean_value = 1; - - // An integer value. - int64 integer_value = 2; - - // A double value. - double double_value = 3; - - // A timestamp value. - // - // Precise only to microseconds. When stored, any additional precision is - // rounded down. - google.protobuf.Timestamp timestamp_value = 10; - - // A string value. - // - // The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. - // Only the first 1,500 bytes of the UTF-8 representation are considered by - // queries. - string string_value = 17; - - // A bytes value. - // - // Must not exceed 1 MiB - 89 bytes. - // Only the first 1,500 bytes are considered by queries. - bytes bytes_value = 18; - - // A reference to a document. For example: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string reference_value = 5; - - // A geo point value representing a point on the surface of Earth. - google.type.LatLng geo_point_value = 8; - - // An array value. - // - // Cannot directly contain another array value, though can contain an - // map which contains another array. - ArrayValue array_value = 9; - - // A map value. - MapValue map_value = 6; - } -} - -// An array value. -message ArrayValue { - // Values in the array. - repeated Value values = 1; -} - -// A map value. -message MapValue { - // The map's fields. - // - // The map keys represent field names. Field names matching the regular - // expression `__.*__` are reserved. Reserved field names are forbidden except - // in certain documented contexts. The map keys, represented as UTF-8, must - // not exceed 1,500 bytes and cannot be empty. - map fields = 1; -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto b/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto deleted file mode 100644 index 17c94ecb4..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto +++ /dev/null @@ -1,912 +0,0 @@ -// 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/firestore/v1/common.proto"; -import "google/firestore/v1/document.proto"; -import "google/firestore/v1/query.proto"; -import "google/firestore/v1/write.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "FirestoreProto"; -option java_package = "com.google.firestore.v1"; -option php_namespace = "Google\\Cloud\\Firestore\\V1"; -option ruby_package = "Google::Cloud::Firestore::V1"; - -// Specification of the Firestore API. - -// The Cloud Firestore service. -// -// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL -// document database that simplifies storing, syncing, and querying data for -// your mobile, web, and IoT apps at global scale. Its client libraries provide -// live synchronization and offline support, while its security features and -// integrations with Firebase and Google Cloud Platform (GCP) accelerate -// building truly serverless apps. -service Firestore { - option (google.api.default_host) = "firestore.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/datastore"; - - // Gets a single document. - rpc GetDocument(GetDocumentRequest) returns (Document) { - option (google.api.http) = { - get: "/v1/{name=projects/*/databases/*/documents/*/**}" - }; - } - - // Lists documents. - rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - additional_bindings { - get: "/v1/{parent=projects/*/databases/*/documents}/{collection_id}" - } - }; - } - - // Updates or inserts a document. - rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { - option (google.api.http) = { - patch: "/v1/{document.name=projects/*/databases/*/documents/*/**}" - body: "document" - }; - option (google.api.method_signature) = "document,update_mask"; - } - - // Deletes a document. - rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/databases/*/documents/*/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets multiple documents. - // - // Documents returned by this method are not guaranteed to be returned in the - // same order that they were requested. - rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:batchGet" - body: "*" - }; - } - - // Starts a new transaction. - rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:beginTransaction" - body: "*" - }; - option (google.api.method_signature) = "database"; - } - - // Commits a transaction, while optionally updating documents. - rpc Commit(CommitRequest) returns (CommitResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:commit" - body: "*" - }; - option (google.api.method_signature) = "database,writes"; - } - - // Rolls back a transaction. - rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:rollback" - body: "*" - }; - option (google.api.method_signature) = "database,transaction"; - } - - // Runs a query. - rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents}:runQuery" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery" - body: "*" - } - }; - } - - // Partitions a query by returning partition cursors that can be used to run - // the query in parallel. The returned partition cursors are split points that - // can be used by RunQuery as starting/end points for the query results. - rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents}:partitionQuery" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" - body: "*" - } - }; - } - - // Streams batches of document updates and deletes, in order. - rpc Write(stream WriteRequest) returns (stream WriteResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:write" - body: "*" - }; - } - - // Listens to changes. - rpc Listen(stream ListenRequest) returns (stream ListenResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:listen" - body: "*" - }; - } - - // Lists all the collection IDs underneath a document. - rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" - body: "*" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Applies a batch of write operations. - // - // The BatchWrite method does not apply the write operations atomically - // and can apply them out of order. Method does not allow more than one write - // per document. Each write succeeds or fails independently. See the - // [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write. - // - // If you require an atomically applied set of writes, use - // [Commit][google.firestore.v1.Firestore.Commit] instead. - rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:batchWrite" - body: "*" - }; - } - - // Creates a new document. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}" - body: "document" - }; - } -} - -// The request for [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument]. -message GetDocumentRequest { - // Required. The resource name of the Document to get. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 2; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads the document in a transaction. - bytes transaction = 3; - - // Reads the version of the document at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 5; - } -} - -// The request for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. -message ListDocumentsRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - // or `messages`. - string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of documents to return. - int32 page_size = 3; - - // The `next_page_token` value returned from a previous List request, if any. - string page_token = 4; - - // The order to sort results by. For example: `priority desc, name`. - string order_by = 6; - - // The fields to return. If not set, returns all fields. - // - // If a document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 7; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents in a transaction. - bytes transaction = 8; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 10; - } - - // If the list should show missing documents. A missing document is a - // document that does not exist but has sub-documents. These documents will - // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1.Document.create_time], - // or [Document.update_time][google.firestore.v1.Document.update_time] set. - // - // Requests with `show_missing` may not specify `where` or - // `order_by`. - bool show_missing = 12; -} - -// The response for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. -message ListDocumentsResponse { - // The Documents found. - repeated Document documents = 1; - - // The next page token. - string next_page_token = 2; -} - -// The request for [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument]. -message CreateDocumentRequest { - // Required. The parent resource. For example: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The client-assigned document ID to use for this document. - // - // Optional. If not specified, an ID will be assigned by the service. - string document_id = 3; - - // Required. The document to create. `name` must not be set. - Document document = 4 [(google.api.field_behavior) = REQUIRED]; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 5; -} - -// The request for [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument]. -message UpdateDocumentRequest { - // Required. The updated document. - // Creates the document if it does not already exist. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The fields to update. - // None of the field paths in the mask may contain a reserved name. - // - // If the document exists on the server and has fields not referenced in the - // mask, they are left unchanged. - // Fields referenced in the mask, but not present in the input document, are - // deleted from the document on the server. - DocumentMask update_mask = 2; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 3; - - // An optional precondition on the document. - // The request will fail if this is set and not met by the target document. - Precondition current_document = 4; -} - -// The request for [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument]. -message DeleteDocumentRequest { - // Required. The resource name of the Document to delete. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // An optional precondition on the document. - // The request will fail if this is set and not met by the target document. - Precondition current_document = 2; -} - -// The request for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. -message BatchGetDocumentsRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The names of the documents to retrieve. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // The request will fail if any of the document is not a child resource of the - // given `database`. Duplicate names will be elided. - repeated string documents = 2; - - // The fields to return. If not set, returns all fields. - // - // If a document has a field that is not present in this mask, that field will - // not be returned in the response. - DocumentMask mask = 3; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents in a transaction. - bytes transaction = 4; - - // Starts a new transaction and reads the documents. - // Defaults to a read-only transaction. - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 5; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 7; - } -} - -// The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. -message BatchGetDocumentsResponse { - // A single result. - // This can be empty if the server is just returning a transaction. - oneof result { - // A document that was requested. - Document found = 1; - - // A document name that was requested but does not exist. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string missing = 2; - } - - // The transaction that was started as part of this request. - // Will only be set in the first response, and only if - // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction] was set in the request. - bytes transaction = 3; - - // The time at which the document was read. - // This may be monotically increasing, in this case the previous documents in - // the result stream are guaranteed not to have changed between their - // read_time and this one. - google.protobuf.Timestamp read_time = 4; -} - -// The request for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. -message BeginTransactionRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The options for the transaction. - // Defaults to a read-write transaction. - TransactionOptions options = 2; -} - -// The response for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. -message BeginTransactionResponse { - // The transaction that was started. - bytes transaction = 1; -} - -// The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. -message CommitRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The writes to apply. - // - // Always executed atomically and in order. - repeated Write writes = 2; - - // If set, applies all writes in this transaction, and commits it. - bytes transaction = 3; -} - -// The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. -message CommitResponse { - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 1; - - // The time at which the commit occurred. Any read with an equal or greater - // `read_time` is guaranteed to see the effects of the commit. - google.protobuf.Timestamp commit_time = 2; -} - -// The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback]. -message RollbackRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The transaction to roll back. - bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. -message RunQueryRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to run. - oneof query_type { - // A structured query. - StructuredQuery structured_query = 2; - } - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Run the query within an already active transaction. - // - // The value here is the opaque transaction ID to execute the query in. - bytes transaction = 5; - - // Starts a new transaction and reads the documents. - // Defaults to a read-only transaction. - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 6; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 7; - } -} - -// The response for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. -message RunQueryResponse { - // The transaction that was started as part of this request. - // Can only be set in the first response, and only if - // [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction] was set in the request. - // If set, no other fields will be set in this response. - bytes transaction = 2; - - // A query result, not set when reporting partial progress. - Document document = 1; - - // The time at which the document was read. This may be monotonically - // increasing; in this case, the previous documents in the result stream are - // guaranteed not to have changed between their `read_time` and this one. - // - // If the query returns no results, a response with `read_time` and no - // `document` will be sent, and this represents the time at which the query - // was run. - google.protobuf.Timestamp read_time = 3; - - // The number of results that have been skipped due to an offset between - // the last response and the current response. - int32 skipped_results = 4; - - // The continuation mode for the query. If present, it indicates the current - // query response stream has finished. This can be set with or without a - // `document` present, but when set, no more results are returned. - oneof continuation_selector { - // If present, Firestore has completely finished the request and no more - // documents will be returned. - bool done = 6; - } -} - -// The request for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. -message PartitionQueryRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents`. - // Document resource names are not supported; only database resource names - // can be specified. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to partition. - oneof query_type { - // A structured query. - // Query must specify collection with all descendants and be ordered by name - // ascending. Other filters, order bys, limits, offsets, and start/end - // cursors are not supported. - StructuredQuery structured_query = 2; - } - - // The desired maximum number of partition points. - // The partitions may be returned across multiple pages of results. - // The number must be positive. The actual number of partitions - // returned may be fewer. - // - // For example, this may be set to one fewer than the number of parallel - // queries to be run, or in running a data pipeline job, one fewer than the - // number of workers or compute instances available. - int64 partition_count = 3; - - // The `next_page_token` value returned from a previous call to - // PartitionQuery that may be used to get an additional set of results. - // There are no ordering guarantees between sets of results. Thus, using - // multiple sets of results will require merging the different result sets. - // - // For example, two subsequent calls using a page_token may return: - // - // * cursor B, cursor M, cursor Q - // * cursor A, cursor U, cursor W - // - // To obtain a complete result set ordered with respect to the results of the - // query supplied to PartitionQuery, the results sets should be merged: - // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - string page_token = 4; - - // The maximum number of partitions to return in this call, subject to - // `partition_count`. - // - // For example, if `partition_count` = 10 and `page_size` = 8, the first call - // to PartitionQuery will return up to 8 partitions and a `next_page_token` - // 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 response for [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. -message PartitionQueryResponse { - // Partition results. - // Each partition is a split point that can be used by RunQuery as a starting - // or end point for the query results. The RunQuery requests must be made with - // the same query supplied to this PartitionQuery request. The partition - // cursors will be ordered according to same ordering as the results of the - // query supplied to PartitionQuery. - // - // For example, if a PartitionQuery request returns partition cursors A and B, - // running the following three queries will return the entire result set of - // the original query: - // - // * query, end_at A - // * query, start_at A, end_at B - // * query, start_at B - // - // An empty result may indicate that the query has too few results to be - // partitioned. - repeated Cursor partitions = 1; - - // A page token that may be used to request an additional set of results, up - // to the number specified by `partition_count` in the PartitionQuery request. - // If blank, there are no more results. - string next_page_token = 2; -} - -// The request for [Firestore.Write][google.firestore.v1.Firestore.Write]. -// -// The first request creates a stream, or resumes an existing one from a token. -// -// When creating a new stream, the server replies with a response containing -// only an ID and a token, to use in the next request. -// -// When resuming a stream, the server first streams any responses later than the -// given token, then a response containing only an up-to-date token, to use in -// the next request. -message WriteRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - // This is only required in the first message. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The ID of the write stream to resume. - // This may only be set in the first message. When left empty, a new write - // stream will be created. - string stream_id = 2; - - // The writes to apply. - // - // Always executed atomically and in order. - // This must be empty on the first request. - // This may be empty on the last request. - // This must not be empty on all other requests. - repeated Write writes = 3; - - // A stream token that was previously sent by the server. - // - // The client should set this field to the token from the most recent - // [WriteResponse][google.firestore.v1.WriteResponse] it has received. This acknowledges that the client has - // received responses up to this token. After sending this token, earlier - // tokens may not be used anymore. - // - // The server may close the stream if there are too many unacknowledged - // responses. - // - // Leave this field unset when creating a new stream. To resume a stream at - // a specific point, set this field and the `stream_id` field. - // - // Leave this field unset when creating a new stream. - bytes stream_token = 4; - - // Labels associated with this write request. - map labels = 5; -} - -// The response for [Firestore.Write][google.firestore.v1.Firestore.Write]. -message WriteResponse { - // The ID of the stream. - // Only set on the first message, when a new stream was created. - string stream_id = 1; - - // A token that represents the position of this response in the stream. - // This can be used by a client to resume the stream at this point. - // - // This field is always set. - bytes stream_token = 2; - - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 3; - - // The time at which the commit occurred. Any read with an equal or greater - // `read_time` is guaranteed to see the effects of the write. - google.protobuf.Timestamp commit_time = 4; -} - -// A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen] -message ListenRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The supported target changes. - oneof target_change { - // A target to add to this stream. - Target add_target = 2; - - // The ID of a target to remove from this stream. - int32 remove_target = 3; - } - - // Labels associated with this target change. - map labels = 4; -} - -// The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen]. -message ListenResponse { - // The supported responses. - oneof response_type { - // Targets have changed. - TargetChange target_change = 2; - - // A [Document][google.firestore.v1.Document] has changed. - DocumentChange document_change = 3; - - // A [Document][google.firestore.v1.Document] has been deleted. - DocumentDelete document_delete = 4; - - // A [Document][google.firestore.v1.Document] has been removed from a target (because it is no longer - // relevant to that target). - DocumentRemove document_remove = 6; - - // A filter to apply to the set of documents previously returned for the - // given target. - // - // Returned when documents may have been removed from the given target, but - // the exact documents are unknown. - ExistenceFilter filter = 5; - } -} - -// A specification of a set of documents to listen to. -message Target { - // A target specified by a set of documents names. - message DocumentsTarget { - // The names of the documents to retrieve. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // The request will fail if any of the document is not a child resource of - // the given `database`. Duplicate names will be elided. - repeated string documents = 2; - } - - // A target specified by a query. - message QueryTarget { - // The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1; - - // The query to run. - oneof query_type { - // A structured query. - StructuredQuery structured_query = 2; - } - } - - // The type of target to listen to. - oneof target_type { - // A target specified by a query. - QueryTarget query = 2; - - // A target specified by a set of document names. - DocumentsTarget documents = 3; - } - - // When to start listening. - // - // If not specified, all matching Documents are returned before any - // subsequent changes. - oneof resume_type { - // A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target. - // - // Using a resume token with a different target is unsupported and may fail. - bytes resume_token = 4; - - // Start listening after a specific `read_time`. - // - // The client must know the state of matching documents at this time. - google.protobuf.Timestamp read_time = 11; - } - - // The target ID that identifies the target on the stream. Must be a positive - // number and non-zero. - int32 target_id = 5; - - // If the target should be removed once it is current and consistent. - bool once = 6; -} - -// Targets being watched have changed. -message TargetChange { - // The type of change. - enum TargetChangeType { - // No change has occurred. Used only to send an updated `resume_token`. - NO_CHANGE = 0; - - // The targets have been added. - ADD = 1; - - // The targets have been removed. - REMOVE = 2; - - // The targets reflect all changes committed before the targets were added - // to the stream. - // - // This will be sent after or with a `read_time` that is greater than or - // equal to the time at which the targets were added. - // - // Listeners can wait for this change if read-after-write semantics - // are desired. - CURRENT = 3; - - // The targets have been reset, and a new initial state for the targets - // will be returned in subsequent changes. - // - // After the initial state is complete, `CURRENT` will be returned even - // if the target was previously indicated to be `CURRENT`. - RESET = 4; - } - - // The type of change that occurred. - TargetChangeType target_change_type = 1; - - // The target IDs of targets that have changed. - // - // If empty, the change applies to all targets. - // - // The order of the target IDs is not defined. - repeated int32 target_ids = 2; - - // The error that resulted in this change, if applicable. - google.rpc.Status cause = 3; - - // A token that can be used to resume the stream for the given `target_ids`, - // or all targets if `target_ids` is empty. - // - // Not set on every target change. - bytes resume_token = 4; - - // The consistent `read_time` for the given `target_ids` (omitted when the - // target_ids are not at a consistent snapshot). - // - // The stream is guaranteed to send a `read_time` with `target_ids` empty - // whenever the entire stream reaches a new consistent snapshot. ADD, - // CURRENT, and RESET messages are guaranteed to (eventually) result in a - // new consistent snapshot (while NO_CHANGE and REMOVE messages are not). - // - // For a given stream, `read_time` is guaranteed to be monotonically - // increasing. - google.protobuf.Timestamp read_time = 6; -} - -// The request for [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. -message ListCollectionIdsRequest { - // Required. The parent document. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of results to return. - int32 page_size = 2; - - // A page token. Must be a value from - // [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. - string page_token = 3; -} - -// The response from [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. -message ListCollectionIdsResponse { - // The collection ids. - repeated string collection_ids = 1; - - // A page token that may be used to continue the list. - string next_page_token = 2; -} - -// The request for [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. -message BatchWriteRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The writes to apply. - // - // Method does not apply writes atomically and does not guarantee ordering. - // Each write succeeds or fails independently. You cannot write to the same - // document more than once per request. - repeated Write writes = 2; - - // Labels associated with this batch write. - map labels = 3; -} - -// The response from [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. -message BatchWriteResponse { - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 1; - - // The status of applying the writes. - // - // This i-th write status corresponds to the i-th write in the - // request. - repeated google.rpc.Status status = 2; -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/query.proto b/owl-bot-staging/v1/protos/google/firestore/v1/query.proto deleted file mode 100644 index 58163eb62..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/query.proto +++ /dev/null @@ -1,304 +0,0 @@ -// 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1; - -import "google/api/field_behavior.proto"; -import "google/firestore/v1/document.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "QueryProto"; -option java_package = "com.google.firestore.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1"; -option ruby_package = "Google::Cloud::Firestore::V1"; - -// A Firestore query. -message StructuredQuery { - // A selection of a collection, such as `messages as m1`. - message CollectionSelector { - // The collection ID. - // When set, selects only collections with this ID. - string collection_id = 2; - - // When false, selects only collections that are immediate children of - // the `parent` specified in the containing `RunQueryRequest`. - // When true, selects all descendant collections. - bool all_descendants = 3; - } - - // A filter. - message Filter { - // The type of filter. - oneof filter_type { - // A composite filter. - CompositeFilter composite_filter = 1; - - // A filter on a document field. - FieldFilter field_filter = 2; - - // A filter that takes exactly one argument. - UnaryFilter unary_filter = 3; - } - } - - // A filter that merges multiple other filters using the given operator. - message CompositeFilter { - // A composite filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // Documents are required to satisfy all of the combined filters. - AND = 1; - } - - // The operator for combining multiple filters. - Operator op = 1; - - // The list of filters to combine. - // - // Requires: - // - // * At least one filter is present. - repeated Filter filters = 2; - } - - // A filter on a specific field. - message FieldFilter { - // A field filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The given `field` is less than the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - LESS_THAN = 1; - - // The given `field` is less than or equal to the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - LESS_THAN_OR_EQUAL = 2; - - // The given `field` is greater than the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - GREATER_THAN = 3; - - // The given `field` is greater than or equal to the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - GREATER_THAN_OR_EQUAL = 4; - - // The given `field` is equal to the given `value`. - EQUAL = 5; - - // The given `field` is not equal to the given `value`. - // - // Requires: - // - // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - NOT_EQUAL = 6; - - // The given `field` is an array that contains the given `value`. - ARRAY_CONTAINS = 7; - - // The given `field` is equal to at least one value in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. - IN = 8; - - // The given `field` is an array that contains any of the values in the - // given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. - ARRAY_CONTAINS_ANY = 9; - - // The value of the `field` is not in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, - // `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - NOT_IN = 10; - } - - // The field to filter by. - FieldReference field = 1; - - // The operator to filter by. - Operator op = 2; - - // The value to compare to. - Value value = 3; - } - - // A filter with a single operand. - message UnaryFilter { - // A unary operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The given `field` is equal to `NaN`. - IS_NAN = 2; - - // The given `field` is equal to `NULL`. - IS_NULL = 3; - - // The given `field` is not equal to `NaN`. - // - // Requires: - // - // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - IS_NOT_NAN = 4; - - // The given `field` is not equal to `NULL`. - // - // Requires: - // - // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - IS_NOT_NULL = 5; - } - - // The unary operator to apply. - Operator op = 1; - - // The argument to the filter. - oneof operand_type { - // The field to which to apply the operator. - FieldReference field = 2; - } - } - - // An order on a field. - message Order { - // The field to order by. - FieldReference field = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; - } - - // A sort direction. - enum Direction { - // Unspecified. - DIRECTION_UNSPECIFIED = 0; - - // Ascending. - ASCENDING = 1; - - // Descending. - DESCENDING = 2; - } - - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - - // The projection of document's fields to return. - message Projection { - // The fields to return. - // - // If empty, all fields are returned. To only return the name - // of the document, use `['__name__']`. - repeated FieldReference fields = 2; - } - - // The projection to return. - Projection select = 1; - - // The collections to query. - repeated CollectionSelector from = 2; - - // The filter to apply. - Filter where = 3; - - // The order to apply to the query results. - // - // Firestore guarantees a stable ordering through the following rules: - // - // * Any field required to appear in `order_by`, that is not already - // specified in `order_by`, is appended to the order in field name order - // by default. - // * If an order on `__name__` is not specified, it is appended by default. - // - // Fields are appended with the same sort direction as the last order - // specified, or 'ASCENDING' if no order was specified. For example: - // - // * `SELECT * FROM Foo ORDER BY A` becomes - // `SELECT * FROM Foo ORDER BY A, __name__` - // * `SELECT * FROM Foo ORDER BY A DESC` becomes - // `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` - // * `SELECT * FROM Foo WHERE A > 1` becomes - // `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` - repeated Order order_by = 4; - - // A starting point for the query results. - Cursor start_at = 7; - - // A end point for the query results. - Cursor end_at = 8; - - // The number of results to skip. - // - // Applies before limit, but after all other constraints. Must be >= 0 if - // specified. - int32 offset = 6; - - // The maximum number of results to return. - // - // Applies after all other constraints. - // Must be >= 0 if specified. - google.protobuf.Int32Value limit = 5; -} - -// A position in a query result set. -message Cursor { - // The values that represent a position, in the order they appear in - // the order by clause of a query. - // - // Can contain fewer values than specified in the order by clause. - repeated Value values = 1; - - // If the position is just before or just after the given values, relative - // to the sort order defined by the query. - bool before = 2; -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/write.proto b/owl-bot-staging/v1/protos/google/firestore/v1/write.proto deleted file mode 100644 index c17e96ad9..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/write.proto +++ /dev/null @@ -1,258 +0,0 @@ -// 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1; - -import "google/firestore/v1/common.proto"; -import "google/firestore/v1/document.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "WriteProto"; -option java_package = "com.google.firestore.v1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1"; -option ruby_package = "Google::Cloud::Firestore::V1"; - -// A write on a document. -message Write { - // The operation to execute. - oneof operation { - // A document to write. - Document update = 1; - - // A document name to delete. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string delete = 2; - - // Applies a transformation to a document. - DocumentTransform transform = 6; - } - - // The fields to update in this write. - // - // This field can be set only when the operation is `update`. - // If the mask is not set for an `update` and the document exists, any - // existing data will be overwritten. - // If the mask is set and the document on the server has fields not covered by - // the mask, they are left unchanged. - // Fields referenced in the mask, but not present in the input document, are - // deleted from the document on the server. - // The field paths in this mask must not contain a reserved field name. - DocumentMask update_mask = 3; - - // The transforms to perform after update. - // - // This field can be set only when the operation is `update`. If present, this - // write is equivalent to performing `update` and `transform` to the same - // document atomically and in order. - repeated DocumentTransform.FieldTransform update_transforms = 7; - - // An optional precondition on the document. - // - // The write will fail if this is set and not met by the target document. - Precondition current_document = 4; -} - -// A transformation of a document. -message DocumentTransform { - // A transformation of a field of the document. - message FieldTransform { - // A value that is calculated by the server. - enum ServerValue { - // Unspecified. This value must not be used. - SERVER_VALUE_UNSPECIFIED = 0; - - // The time at which the server processed the request, with millisecond - // precision. If used on multiple fields (same or different documents) in - // a transaction, all the fields will get the same server timestamp. - REQUEST_TIME = 1; - } - - // The path of the field. See [Document.fields][google.firestore.v1.Document.fields] for the field path syntax - // reference. - string field_path = 1; - - // The transformation to apply on the field. - oneof transform_type { - // Sets the field to the given server value. - ServerValue set_to_server_value = 2; - - // Adds the given value to the field's current value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the given value. - // If either of the given value or the current field value are doubles, - // both values will be interpreted as doubles. Double arithmetic and - // representation of double values follow IEEE 754 semantics. - // If there is positive/negative integer overflow, the field is resolved - // to the largest magnitude positive/negative integer. - Value increment = 3; - - // Sets the field to the maximum of its current value and the given value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the given value. - // If a maximum operation is applied where the field and the input value - // are of mixed types (that is - one is an integer and one is a double) - // the field takes on the type of the larger operand. If the operands are - // equivalent (e.g. 3 and 3.0), the field does not change. - // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and - // zero input value is always the stored value. - // The maximum of any numeric value x and NaN is NaN. - Value maximum = 4; - - // Sets the field to the minimum of its current value and the given value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the input value. - // If a minimum operation is applied where the field and the input value - // are of mixed types (that is - one is an integer and one is a double) - // the field takes on the type of the smaller operand. If the operands are - // equivalent (e.g. 3 and 3.0), the field does not change. - // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and - // zero input value is always the stored value. - // The minimum of any numeric value x and NaN is NaN. - Value minimum = 5; - - // Append the given elements in order if they are not already present in - // the current field value. - // If the field is not an array, or if the field does not yet exist, it is - // first set to the empty array. - // - // Equivalent numbers of different types (e.g. 3L and 3.0) are - // considered equal when checking if a value is missing. - // NaN is equal to NaN, and Null is equal to Null. - // If the input contains multiple equivalent values, only the first will - // be considered. - // - // The corresponding transform_result will be the null value. - ArrayValue append_missing_elements = 6; - - // Remove all of the given elements from the array in the field. - // If the field is not an array, or if the field does not yet exist, it is - // set to the empty array. - // - // Equivalent numbers of the different types (e.g. 3L and 3.0) are - // considered equal when deciding whether an element should be removed. - // NaN is equal to NaN, and Null is equal to Null. - // This will remove all equivalent values if there are duplicates. - // - // The corresponding transform_result will be the null value. - ArrayValue remove_all_from_array = 7; - } - } - - // The name of the document to transform. - string document = 1; - - // The list of transformations to apply to the fields of the document, in - // order. - // This must not be empty. - repeated FieldTransform field_transforms = 2; -} - -// The result of applying a write. -message WriteResult { - // The last update time of the document after applying the write. Not set - // after a `delete`. - // - // If the write did not actually change the document, this will be the - // previous update_time. - google.protobuf.Timestamp update_time = 1; - - // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform], in the - // same order. - repeated Value transform_results = 2; -} - -// A [Document][google.firestore.v1.Document] has changed. -// -// May be the result of multiple [writes][google.firestore.v1.Write], including deletes, that -// ultimately resulted in a new value for the [Document][google.firestore.v1.Document]. -// -// Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be returned for the same logical -// change, if multiple targets are affected. -message DocumentChange { - // The new state of the [Document][google.firestore.v1.Document]. - // - // If `mask` is set, contains only fields that were updated or added. - Document document = 1; - - // A set of target IDs of targets that match this document. - repeated int32 target_ids = 5; - - // A set of target IDs for targets that no longer match this document. - repeated int32 removed_target_ids = 6; -} - -// A [Document][google.firestore.v1.Document] has been deleted. -// -// May be the result of multiple [writes][google.firestore.v1.Write], including updates, the -// last of which deleted the [Document][google.firestore.v1.Document]. -// -// Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be returned for the same logical -// delete, if multiple targets are affected. -message DocumentDelete { - // The resource name of the [Document][google.firestore.v1.Document] that was deleted. - string document = 1; - - // A set of target IDs for targets that previously matched this entity. - repeated int32 removed_target_ids = 6; - - // The read timestamp at which the delete was observed. - // - // Greater or equal to the `commit_time` of the delete. - google.protobuf.Timestamp read_time = 4; -} - -// A [Document][google.firestore.v1.Document] has been removed from the view of the targets. -// -// Sent if the document is no longer relevant to a target and is out of view. -// Can be sent instead of a DocumentDelete or a DocumentChange if the server -// can not send the new value of the document. -// -// Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be returned for the same logical -// write or delete, if multiple targets are affected. -message DocumentRemove { - // The resource name of the [Document][google.firestore.v1.Document] that has gone out of view. - string document = 1; - - // A set of target IDs for targets that previously matched this document. - repeated int32 removed_target_ids = 2; - - // The read timestamp at which the remove was observed. - // - // Greater or equal to the `commit_time` of the change/delete/remove. - google.protobuf.Timestamp read_time = 4; -} - -// A digest of all the documents that match a given target. -message ExistenceFilter { - // The target ID to which this filter applies. - int32 target_id = 1; - - // The total count of documents that match [target_id][google.firestore.v1.ExistenceFilter.target_id]. - // - // If different from the count of documents in the client that match, the - // client must manually determine which documents no longer match the target. - int32 count = 2; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js deleted file mode 100644 index 68adcc61c..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js +++ /dev/null @@ -1,90 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_BatchGetDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - */ - // const documents = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If a document has a field that is not present in this mask, that field will - * not be returned in the response. - */ - // const mask = {} - /** - * Reads documents in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBatchGetDocuments() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.batchGetDocuments(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callBatchGetDocuments(); - // [END firestore_v1_generated_Firestore_BatchGetDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js deleted file mode 100644 index 728b5c4dd..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js +++ /dev/null @@ -1,70 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_BatchWrite_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The writes to apply. - * Method does not apply writes atomically and does not guarantee ordering. - * Each write succeeds or fails independently. You cannot write to the same - * document more than once per request. - */ - // const writes = 1234 - /** - * Labels associated with this batch write. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBatchWrite() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.batchWrite(request); - console.log(response); - } - - callBatchWrite(); - // [END firestore_v1_generated_Firestore_BatchWrite_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js b/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js deleted file mode 100644 index 6a6db3aa6..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_BeginTransaction_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The options for the transaction. - * Defaults to a read-write transaction. - */ - // const options = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBeginTransaction() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.beginTransaction(request); - console.log(response); - } - - callBeginTransaction(); - // [END firestore_v1_generated_Firestore_BeginTransaction_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js b/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js deleted file mode 100644 index b249f2ddd..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js +++ /dev/null @@ -1,68 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_Commit_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The writes to apply. - * Always executed atomically and in order. - */ - // const writes = 1234 - /** - * If set, applies all writes in this transaction, and commits it. - */ - // const transaction = 'Buffer.from('string')' - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callCommit() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.commit(request); - console.log(response); - } - - callCommit(); - // [END firestore_v1_generated_Firestore_Commit_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js deleted file mode 100644 index dc2db3111..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js +++ /dev/null @@ -1,81 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, collectionId, document) { - // [START firestore_v1_generated_Firestore_CreateDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - */ - // const parent = 'abc123' - /** - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - */ - // const collectionId = 'abc123' - /** - * The client-assigned document ID to use for this document. - * Optional. If not specified, an ID will be assigned by the service. - */ - // const documentId = 'abc123' - /** - * Required. The document to create. `name` must not be set. - */ - // const document = {} - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callCreateDocument() { - // Construct request - const request = { - parent, - collectionId, - document, - }; - - // Run request - const response = await firestoreClient.createDocument(request); - console.log(response); - } - - callCreateDocument(); - // [END firestore_v1_generated_Firestore_CreateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js deleted file mode 100644 index 0c2404f89..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_Firestore_DeleteDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - */ - // const name = 'abc123' - /** - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - */ - // const currentDocument = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callDeleteDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await firestoreClient.deleteDocument(request); - console.log(response); - } - - callDeleteDocument(); - // [END firestore_v1_generated_Firestore_DeleteDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js deleted file mode 100644 index 83510ea5b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js +++ /dev/null @@ -1,74 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1_generated_Firestore_GetDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - */ - // const name = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * Reads the document in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Reads the version of the document at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callGetDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await firestoreClient.getDocument(request); - console.log(response); - } - - callGetDocument(); - // [END firestore_v1_generated_Firestore_GetDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js b/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js deleted file mode 100644 index 2e73185e0..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js +++ /dev/null @@ -1,72 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_Firestore_ListCollectionIds_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A page token. Must be a value from - * ListCollectionIdsResponse google.firestore.v1.ListCollectionIdsResponse. - */ - // const pageToken = 'abc123' - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListCollectionIds() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await firestoreClient.listCollectionIdsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCollectionIds(); - // [END firestore_v1_generated_Firestore_ListCollectionIds_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js b/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js deleted file mode 100644 index 0f654ff55..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js +++ /dev/null @@ -1,107 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, collectionId) { - // [START firestore_v1_generated_Firestore_ListDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - */ - // const collectionId = 'abc123' - /** - * The maximum number of documents to return. - */ - // const pageSize = 1234 - /** - * The `next_page_token` value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * The order to sort results by. For example: `priority desc, name`. - */ - // const orderBy = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * Reads documents in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - /** - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, Document.create_time google.firestore.v1.Document.create_time, - * or Document.update_time google.firestore.v1.Document.update_time set. - * Requests with `show_missing` may not specify `where` or - * `order_by`. - */ - // const showMissing = true - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListDocuments() { - // Construct request - const request = { - parent, - collectionId, - }; - - // Run request - const iterable = await firestoreClient.listDocumentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDocuments(); - // [END firestore_v1_generated_Firestore_ListDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js b/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js deleted file mode 100644 index 65b65ef4a..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js +++ /dev/null @@ -1,75 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_Listen_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * A target to add to this stream. - */ - // const addTarget = {} - /** - * The ID of a target to remove from this stream. - */ - // const removeTarget = 1234 - /** - * Labels associated with this target change. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListen() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.listen(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callListen(); - // [END firestore_v1_generated_Firestore_Listen_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js deleted file mode 100644 index b5c0187a7..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js +++ /dev/null @@ -1,102 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_Firestore_PartitionQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - */ - // const parent = 'abc123' - /** - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - */ - // const structuredQuery = {} - /** - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - */ - // const partitionCount = 1234 - /** - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * For example, two subsequent calls using a page_token may return: - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - */ - // const pageToken = 'abc123' - /** - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - */ - // const pageSize = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callPartitionQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await firestoreClient.partitionQueryAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callPartitionQuery(); - // [END firestore_v1_generated_Firestore_PartitionQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js b/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js deleted file mode 100644 index 3ca8a0eed..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database, transaction) { - // [START firestore_v1_generated_Firestore_Rollback_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * Required. The transaction to roll back. - */ - // const transaction = 'Buffer.from('string')' - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRollback() { - // Construct request - const request = { - database, - transaction, - }; - - // Run request - const response = await firestoreClient.rollback(request); - console.log(response); - } - - callRollback(); - // [END firestore_v1_generated_Firestore_Rollback_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js deleted file mode 100644 index dac2ee27b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js +++ /dev/null @@ -1,86 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1_generated_Firestore_RunQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * A structured query. - */ - // const structuredQuery = {} - /** - * Run the query within an already active transaction. - * The value here is the opaque transaction ID to execute the query in. - */ - // const transaction = 'Buffer.from('string')' - /** - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRunQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const stream = await firestoreClient.runQuery(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callRunQuery(); - // [END firestore_v1_generated_Firestore_RunQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js b/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js deleted file mode 100644 index e8c38a660..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js +++ /dev/null @@ -1,79 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(document) { - // [START firestore_v1_generated_Firestore_UpdateDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The updated document. - * Creates the document if it does not already exist. - */ - // const document = {} - /** - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - */ - // const updateMask = {} - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - */ - // const currentDocument = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callUpdateDocument() { - // Construct request - const request = { - document, - }; - - // Run request - const response = await firestoreClient.updateDocument(request); - console.log(response); - } - - callUpdateDocument(); - // [END firestore_v1_generated_Firestore_UpdateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/firestore.write.js b/owl-bot-staging/v1/samples/generated/v1/firestore.write.js deleted file mode 100644 index 222755de7..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.write.js +++ /dev/null @@ -1,95 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1_generated_Firestore_Write_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * This is only required in the first message. - */ - // const database = 'abc123' - /** - * The ID of the write stream to resume. - * This may only be set in the first message. When left empty, a new write - * stream will be created. - */ - // const streamId = 'abc123' - /** - * The writes to apply. - * Always executed atomically and in order. - * This must be empty on the first request. - * This may be empty on the last request. - * This must not be empty on all other requests. - */ - // const writes = 1234 - /** - * A stream token that was previously sent by the server. - * The client should set this field to the token from the most recent - * WriteResponse google.firestore.v1.WriteResponse it has received. This acknowledges that the client has - * received responses up to this token. After sending this token, earlier - * tokens may not be used anymore. - * The server may close the stream if there are too many unacknowledged - * responses. - * Leave this field unset when creating a new stream. To resume a stream at - * a specific point, set this field and the `stream_id` field. - * Leave this field unset when creating a new stream. - */ - // const streamToken = 'Buffer.from('string')' - /** - * Labels associated with this write request. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callWrite() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.write(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callWrite(); - // [END firestore_v1_generated_Firestore_Write_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json deleted file mode 100644 index f5b6b402e..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.firestore.v1.json +++ /dev/null @@ -1,803 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-firestore", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.firestore.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "firestore_v1_generated_Firestore_GetDocument_async", - "title": "Firestore getDocument Sample", - "origin": "API_DEFINITION", - "description": " Gets a single document.", - "canonical": true, - "file": "firestore.get_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocument", - "fullName": "google.firestore.v1.Firestore.GetDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "mask", - "type": ".google.firestore.v1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "GetDocument", - "fullName": "google.firestore.v1.Firestore.GetDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_ListDocuments_async", - "title": "Firestore listDocuments Sample", - "origin": "API_DEFINITION", - "description": " Lists documents.", - "canonical": true, - "file": "firestore.list_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 99, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDocuments", - "fullName": "google.firestore.v1.Firestore.ListDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "collection_id", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "mask", - "type": ".google.firestore.v1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "show_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.firestore.v1.ListDocumentsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "ListDocuments", - "fullName": "google.firestore.v1.Firestore.ListDocuments", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_UpdateDocument_async", - "title": "Firestore updateDocument Sample", - "origin": "API_DEFINITION", - "description": " Updates or inserts a document.", - "canonical": true, - "file": "firestore.update_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocument", - "fullName": "google.firestore.v1.Firestore.UpdateDocument", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.firestore.v1.Document" - }, - { - "name": "update_mask", - "type": ".google.firestore.v1.DocumentMask" - }, - { - "name": "mask", - "type": ".google.firestore.v1.DocumentMask" - }, - { - "name": "current_document", - "type": ".google.firestore.v1.Precondition" - } - ], - "resultType": ".google.firestore.v1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "UpdateDocument", - "fullName": "google.firestore.v1.Firestore.UpdateDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_DeleteDocument_async", - "title": "Firestore deleteDocument Sample", - "origin": "API_DEFINITION", - "description": " Deletes a document.", - "canonical": true, - "file": "firestore.delete_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocument", - "fullName": "google.firestore.v1.Firestore.DeleteDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "current_document", - "type": ".google.firestore.v1.Precondition" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "DeleteDocument", - "fullName": "google.firestore.v1.Firestore.DeleteDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_BatchGetDocuments_async", - "title": "Firestore batchGetDocuments Sample", - "origin": "API_DEFINITION", - "description": " Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.", - "canonical": true, - "file": "firestore.batch_get_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchGetDocuments", - "fullName": "google.firestore.v1.Firestore.BatchGetDocuments", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "documents", - "type": "TYPE_STRING[]" - }, - { - "name": "mask", - "type": ".google.firestore.v1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1.BatchGetDocumentsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "BatchGetDocuments", - "fullName": "google.firestore.v1.Firestore.BatchGetDocuments", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_BeginTransaction_async", - "title": "Firestore beginTransaction Sample", - "origin": "API_DEFINITION", - "description": " Starts a new transaction.", - "canonical": true, - "file": "firestore.begin_transaction.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BeginTransaction", - "fullName": "google.firestore.v1.Firestore.BeginTransaction", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.firestore.v1.TransactionOptions" - } - ], - "resultType": ".google.firestore.v1.BeginTransactionResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "BeginTransaction", - "fullName": "google.firestore.v1.Firestore.BeginTransaction", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_Commit_async", - "title": "Firestore commit Sample", - "origin": "API_DEFINITION", - "description": " Commits a transaction, while optionally updating documents.", - "canonical": true, - "file": "firestore.commit.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Commit", - "fullName": "google.firestore.v1.Firestore.Commit", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.firestore.v1.CommitResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "Commit", - "fullName": "google.firestore.v1.Firestore.Commit", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_Rollback_async", - "title": "Firestore rollback Sample", - "origin": "API_DEFINITION", - "description": " Rolls back a transaction.", - "canonical": true, - "file": "firestore.rollback.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Rollback", - "fullName": "google.firestore.v1.Firestore.Rollback", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "Rollback", - "fullName": "google.firestore.v1.Firestore.Rollback", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_RunQuery_async", - "title": "Firestore runQuery Sample", - "origin": "API_DEFINITION", - "description": " Runs a query.", - "canonical": true, - "file": "firestore.run_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunQuery", - "fullName": "google.firestore.v1.Firestore.RunQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_query", - "type": ".google.firestore.v1.StructuredQuery" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1.RunQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "RunQuery", - "fullName": "google.firestore.v1.Firestore.RunQuery", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_PartitionQuery_async", - "title": "Firestore partitionQuery Sample", - "origin": "API_DEFINITION", - "description": " Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.", - "canonical": true, - "file": "firestore.partition_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 94, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PartitionQuery", - "fullName": "google.firestore.v1.Firestore.PartitionQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_query", - "type": ".google.firestore.v1.StructuredQuery" - }, - { - "name": "partition_count", - "type": "TYPE_INT64" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.firestore.v1.PartitionQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "PartitionQuery", - "fullName": "google.firestore.v1.Firestore.PartitionQuery", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_Write_async", - "title": "Firestore write Sample", - "origin": "API_DEFINITION", - "description": " Streams batches of document updates and deletes, in order.", - "canonical": true, - "file": "firestore.write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Write", - "fullName": "google.firestore.v1.Firestore.Write", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "stream_id", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "stream_token", - "type": "TYPE_BYTES" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1.WriteResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "Write", - "fullName": "google.firestore.v1.Firestore.Write", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_Listen_async", - "title": "Firestore listen Sample", - "origin": "API_DEFINITION", - "description": " Listens to changes.", - "canonical": true, - "file": "firestore.listen.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Listen", - "fullName": "google.firestore.v1.Firestore.Listen", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "add_target", - "type": ".google.firestore.v1.Target" - }, - { - "name": "remove_target", - "type": "TYPE_INT32" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1.ListenResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "Listen", - "fullName": "google.firestore.v1.Firestore.Listen", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_ListCollectionIds_async", - "title": "Firestore listCollectionIds Sample", - "origin": "API_DEFINITION", - "description": " Lists all the collection IDs underneath a document.", - "canonical": true, - "file": "firestore.list_collection_ids.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCollectionIds", - "fullName": "google.firestore.v1.Firestore.ListCollectionIds", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.v1.ListCollectionIdsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "ListCollectionIds", - "fullName": "google.firestore.v1.Firestore.ListCollectionIds", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_BatchWrite_async", - "title": "Firestore batchWrite Sample", - "origin": "API_DEFINITION", - "description": " Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1.BatchWriteResponse] for the success status of each write. If you require an atomically applied set of writes, use [Commit][google.firestore.v1.Firestore.Commit] instead.", - "canonical": true, - "file": "firestore.batch_write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchWrite", - "fullName": "google.firestore.v1.Firestore.BatchWrite", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1.BatchWriteResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "BatchWrite", - "fullName": "google.firestore.v1.Firestore.BatchWrite", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1_generated_Firestore_CreateDocument_async", - "title": "Firestore createDocument Sample", - "origin": "API_DEFINITION", - "description": " Creates a new document.", - "canonical": true, - "file": "firestore.create_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocument", - "fullName": "google.firestore.v1.Firestore.CreateDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "collection_id", - "type": "TYPE_STRING" - }, - { - "name": "document_id", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.firestore.v1.Document" - }, - { - "name": "mask", - "type": ".google.firestore.v1.DocumentMask" - } - ], - "resultType": ".google.firestore.v1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "CreateDocument", - "fullName": "google.firestore.v1.Firestore.CreateDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1.Firestore" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index fded33a5a..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const FirestoreClient = v1.FirestoreClient; -type FirestoreClient = v1.FirestoreClient; -export {v1, FirestoreClient}; -export default {v1, FirestoreClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/firestore_client.ts b/owl-bot-staging/v1/src/v1/firestore_client.ts deleted file mode 100644 index 2c93c6d5c..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client.ts +++ /dev/null @@ -1,1857 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, GoogleError} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import { PassThrough } from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/firestore_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './firestore_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * The Cloud Firestore service. - * - * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL - * document database that simplifies storing, syncing, and querying data for - * your mobile, web, and IoT apps at global scale. Its client libraries provide - * live synchronization and offline support, while its security features and - * integrations with Firebase and Google Cloud Platform (GCP) accelerate - * building truly serverless apps. - * @class - * @memberof v1 - */ -export class FirestoreClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - firestoreStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FirestoreClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof FirestoreClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listDocuments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'), - partitionQuery: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'), - listCollectionIds: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds') - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this.descriptors.stream = { - batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.firestore.v1.Firestore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.firestoreStub) { - return this.firestoreStub; - } - - // Put together the "service stub" for - // google.firestore.v1.Firestore. - this.firestoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.firestore.v1.Firestore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.firestore.v1.Firestore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreStubMethods = - ['getDocument', 'listDocuments', 'updateDocument', 'deleteDocument', 'batchGetDocuments', 'beginTransaction', 'commit', 'rollback', 'runQuery', 'partitionQuery', 'write', 'listen', 'listCollectionIds', 'batchWrite', 'createDocument']; - for (const methodName of firestoreStubMethods) { - const callPromise = this.firestoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough(); - setImmediate(() => { - stream.emit('error', new GoogleError('The client has already been closed.')); - }); - return stream; - } - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.firestoreStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads the document in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads the version of the document at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.get_document.js - * region_tag:firestore_v1_generated_Firestore_GetDocument_async - */ - getDocument( - request?: protos.google.firestore.v1.IGetDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|undefined, {}|undefined - ]>; - getDocument( - request: protos.google.firestore.v1.IGetDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request: protos.google.firestore.v1.IGetDocumentRequest, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request?: protos.google.firestore.v1.IGetDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IGetDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getDocument(request, options, callback); - } -/** - * Updates or inserts a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.firestore.v1.Document} request.document - * Required. The updated document. - * Creates the document if it does not already exist. - * @param {google.firestore.v1.DocumentMask} request.updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {google.firestore.v1.Precondition} request.currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.update_document.js - * region_tag:firestore_v1_generated_Firestore_UpdateDocument_async - */ - updateDocument( - request?: protos.google.firestore.v1.IUpdateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>; - updateDocument( - request: protos.google.firestore.v1.IUpdateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request: protos.google.firestore.v1.IUpdateDocumentRequest, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request?: protos.google.firestore.v1.IUpdateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'document.name': request.document!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateDocument(request, options, callback); - } -/** - * Deletes a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {google.firestore.v1.Precondition} request.currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.delete_document.js - * region_tag:firestore_v1_generated_Firestore_DeleteDocument_async - */ - deleteDocument( - request?: protos.google.firestore.v1.IDeleteDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>; - deleteDocument( - request: protos.google.firestore.v1.IDeleteDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request: protos.google.firestore.v1.IDeleteDocumentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request?: protos.google.firestore.v1.IDeleteDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteDocument(request, options, callback); - } -/** - * Starts a new transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {google.firestore.v1.TransactionOptions} request.options - * The options for the transaction. - * Defaults to a read-write transaction. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1.BeginTransactionResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.begin_transaction.js - * region_tag:firestore_v1_generated_Firestore_BeginTransaction_async - */ - beginTransaction( - request?: protos.google.firestore.v1.IBeginTransactionRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|undefined, {}|undefined - ]>; - beginTransaction( - request: protos.google.firestore.v1.IBeginTransactionRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request: protos.google.firestore.v1.IBeginTransactionRequest, - callback: Callback< - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request?: protos.google.firestore.v1.IBeginTransactionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.IBeginTransactionResponse, - protos.google.firestore.v1.IBeginTransactionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.beginTransaction(request, options, callback); - } -/** - * Commits a transaction, while optionally updating documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {number[]} request.writes - * The writes to apply. - * - * Always executed atomically and in order. - * @param {Buffer} request.transaction - * If set, applies all writes in this transaction, and commits it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1.CommitResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.commit.js - * region_tag:firestore_v1_generated_Firestore_Commit_async - */ - commit( - request?: protos.google.firestore.v1.ICommitRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|undefined, {}|undefined - ]>; - commit( - request: protos.google.firestore.v1.ICommitRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request: protos.google.firestore.v1.ICommitRequest, - callback: Callback< - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request?: protos.google.firestore.v1.ICommitRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.ICommitResponse, - protos.google.firestore.v1.ICommitRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.commit(request, options, callback); - } -/** - * Rolls back a transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Buffer} request.transaction - * Required. The transaction to roll back. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.rollback.js - * region_tag:firestore_v1_generated_Firestore_Rollback_async - */ - rollback( - request?: protos.google.firestore.v1.IRollbackRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|undefined, {}|undefined - ]>; - rollback( - request: protos.google.firestore.v1.IRollbackRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request: protos.google.firestore.v1.IRollbackRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request?: protos.google.firestore.v1.IRollbackRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1.IRollbackRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.rollback(request, options, callback); - } -/** - * Applies a batch of write operations. - * - * The BatchWrite method does not apply the write operations atomically - * and can apply them out of order. Method does not allow more than one write - * per document. Each write succeeds or fails independently. See the - * {@link google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link google.firestore.v1.Firestore.Commit|Commit} instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {number[]} request.writes - * The writes to apply. - * - * Method does not apply writes atomically and does not guarantee ordering. - * Each write succeeds or fails independently. You cannot write to the same - * document more than once per request. - * @param {number[]} request.labels - * Labels associated with this batch write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchWriteResponse]{@link google.firestore.v1.BatchWriteResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.batch_write.js - * region_tag:firestore_v1_generated_Firestore_BatchWrite_async - */ - batchWrite( - request?: protos.google.firestore.v1.IBatchWriteRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|undefined, {}|undefined - ]>; - batchWrite( - request: protos.google.firestore.v1.IBatchWriteRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): void; - batchWrite( - request: protos.google.firestore.v1.IBatchWriteRequest, - callback: Callback< - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): void; - batchWrite( - request?: protos.google.firestore.v1.IBatchWriteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.IBatchWriteResponse, - protos.google.firestore.v1.IBatchWriteRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.batchWrite(request, options, callback); - } -/** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {google.firestore.v1.Document} request.document - * Required. The document to create. `name` must not be set. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/firestore.create_document.js - * region_tag:firestore_v1_generated_Firestore_CreateDocument_async - */ - createDocument( - request?: protos.google.firestore.v1.ICreateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>; - createDocument( - request: protos.google.firestore.v1.ICreateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request: protos.google.firestore.v1.ICreateDocumentRequest, - callback: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request?: protos.google.firestore.v1.ICreateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1.IDocument, - protos.google.firestore.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createDocument(request, options, callback); - } - -/** - * Gets multiple documents. - * - * Documents returned by this method are not guaranteed to be returned in the - * same order that they were requested. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field will - * not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.firestore.v1.TransactionOptions} request.newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1.BatchGetDocumentsResponse} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - * @example include:samples/generated/v1/firestore.batch_get_documents.js - * region_tag:firestore_v1_generated_Firestore_BatchGetDocuments_async - */ - batchGetDocuments( - request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.batchGetDocuments(request, options); - } - -/** - * Runs a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {google.firestore.v1.StructuredQuery} request.structuredQuery - * A structured query. - * @param {Buffer} request.transaction - * Run the query within an already active transaction. - * - * The value here is the opaque transaction ID to execute the query in. - * @param {google.firestore.v1.TransactionOptions} request.newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits [RunQueryResponse]{@link google.firestore.v1.RunQueryResponse} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - * @example include:samples/generated/v1/firestore.run_query.js - * region_tag:firestore_v1_generated_Firestore_RunQuery_async - */ - runQuery( - request?: protos.google.firestore.v1.IRunQueryRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.runQuery(request, options); - } - -/** - * Streams batches of document updates and deletes, in order. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [WriteRequest]{@link google.firestore.v1.WriteRequest} for write() method, and - * will emit objects representing [WriteResponse]{@link google.firestore.v1.WriteResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1/firestore.write.js - * region_tag:firestore_v1_generated_Firestore_Write_async - */ - write( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.write(null, options); - } - -/** - * Listens to changes. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [ListenRequest]{@link google.firestore.v1.ListenRequest} for write() method, and - * will emit objects representing [ListenResponse]{@link google.firestore.v1.ListenResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1/firestore.listen.js - * region_tag:firestore_v1_generated_Firestore_Listen_async - */ - listen( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.listen(null, options); - } - - /** - * Lists documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Document]{@link google.firestore.v1.Document}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocuments( - request?: protos.google.firestore.v1.IListDocumentsRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.IDocument[], - protos.google.firestore.v1.IListDocumentsRequest|null, - protos.google.firestore.v1.IListDocumentsResponse - ]>; - listDocuments( - request: protos.google.firestore.v1.IListDocumentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1.IListDocumentsRequest, - protos.google.firestore.v1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1.IDocument>): void; - listDocuments( - request: protos.google.firestore.v1.IListDocumentsRequest, - callback: PaginationCallback< - protos.google.firestore.v1.IListDocumentsRequest, - protos.google.firestore.v1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1.IDocument>): void; - listDocuments( - request?: protos.google.firestore.v1.IListDocumentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1.IListDocumentsRequest, - protos.google.firestore.v1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1.IDocument>, - callback?: PaginationCallback< - protos.google.firestore.v1.IListDocumentsRequest, - protos.google.firestore.v1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1.IDocument>): - Promise<[ - protos.google.firestore.v1.IDocument[], - protos.google.firestore.v1.IListDocumentsRequest|null, - protos.google.firestore.v1.IListDocumentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listDocuments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Document]{@link google.firestore.v1.Document} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocumentsStream( - request?: protos.google.firestore.v1.IListDocumentsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDocuments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Document]{@link google.firestore.v1.Document}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/firestore.list_documents.js - * region_tag:firestore_v1_generated_Firestore_ListDocuments_async - */ - listDocumentsAsync( - request?: protos.google.firestore.v1.IListDocumentsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.asyncIterate( - this.innerApiCalls['listDocuments'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Partitions a query by returning partition cursors that can be used to run - * the query in parallel. The returned partition cursors are split points that - * can be used by RunQuery as starting/end points for the query results. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Cursor]{@link google.firestore.v1.Cursor}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `partitionQueryAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - partitionQuery( - request?: protos.google.firestore.v1.IPartitionQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1.ICursor[], - protos.google.firestore.v1.IPartitionQueryRequest|null, - protos.google.firestore.v1.IPartitionQueryResponse - ]>; - partitionQuery( - request: protos.google.firestore.v1.IPartitionQueryRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1.IPartitionQueryRequest, - protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1.ICursor>): void; - partitionQuery( - request: protos.google.firestore.v1.IPartitionQueryRequest, - callback: PaginationCallback< - protos.google.firestore.v1.IPartitionQueryRequest, - protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1.ICursor>): void; - partitionQuery( - request?: protos.google.firestore.v1.IPartitionQueryRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1.IPartitionQueryRequest, - protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1.ICursor>, - callback?: PaginationCallback< - protos.google.firestore.v1.IPartitionQueryRequest, - protos.google.firestore.v1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1.ICursor>): - Promise<[ - protos.google.firestore.v1.ICursor[], - protos.google.firestore.v1.IPartitionQueryRequest|null, - protos.google.firestore.v1.IPartitionQueryResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.partitionQuery(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Cursor]{@link google.firestore.v1.Cursor} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `partitionQueryAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - partitionQueryStream( - request?: protos.google.firestore.v1.IPartitionQueryRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['partitionQuery']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.partitionQuery.createStream( - this.innerApiCalls.partitionQuery as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `partitionQuery`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Cursor]{@link google.firestore.v1.Cursor}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/firestore.partition_query.js - * region_tag:firestore_v1_generated_Firestore_PartitionQuery_async - */ - partitionQueryAsync( - request?: protos.google.firestore.v1.IPartitionQueryRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['partitionQuery']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.partitionQuery.asyncIterate( - this.innerApiCalls['partitionQuery'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Lists all the collection IDs underneath a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of string. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCollectionIdsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCollectionIds( - request?: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: CallOptions): - Promise<[ - string[], - protos.google.firestore.v1.IListCollectionIdsRequest|null, - protos.google.firestore.v1.IListCollectionIdsResponse - ]>; - listCollectionIds( - request: protos.google.firestore.v1.IListCollectionIdsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1.IListCollectionIdsRequest, - protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, - string>): void; - listCollectionIds( - request: protos.google.firestore.v1.IListCollectionIdsRequest, - callback: PaginationCallback< - protos.google.firestore.v1.IListCollectionIdsRequest, - protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, - string>): void; - listCollectionIds( - request?: protos.google.firestore.v1.IListCollectionIdsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1.IListCollectionIdsRequest, - protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, - string>, - callback?: PaginationCallback< - protos.google.firestore.v1.IListCollectionIdsRequest, - protos.google.firestore.v1.IListCollectionIdsResponse|null|undefined, - string>): - Promise<[ - string[], - protos.google.firestore.v1.IListCollectionIdsRequest|null, - protos.google.firestore.v1.IListCollectionIdsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCollectionIds(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing string on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCollectionIdsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCollectionIdsStream( - request?: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCollectionIds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectionIds.createStream( - this.innerApiCalls.listCollectionIds as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCollectionIds`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * string. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/firestore.list_collection_ids.js - * region_tag:firestore_v1_generated_Firestore_ListCollectionIds_async - */ - listCollectionIdsAsync( - request?: protos.google.firestore.v1.IListCollectionIdsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCollectionIds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectionIds.asyncIterate( - this.innerApiCalls['listCollectionIds'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.firestoreStub && !this._terminated) { - return this.firestoreStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/firestore_client_config.json b/owl-bot-staging/v1/src/v1/firestore_client_config.json deleted file mode 100644 index 65c9d8705..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client_config.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "interfaces": { - "google.firestore.v1.Firestore": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "deadline_exceeded_resource_exhausted_internal_unavailable": [ - "DEADLINE_EXCEEDED", - "RESOURCE_EXHAUSTED", - "INTERNAL", - "UNAVAILABLE" - ], - "resource_exhausted_unavailable": [ - "RESOURCE_EXHAUSTED", - "UNAVAILABLE" - ], - "resource_exhausted_aborted_unavailable": [ - "RESOURCE_EXHAUSTED", - "ABORTED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetDocument": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "ListDocuments": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "UpdateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "resource_exhausted_unavailable", - "retry_params_name": "default" - }, - "DeleteDocument": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "BatchGetDocuments": { - "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "BeginTransaction": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "Commit": { - "timeout_millis": 60000, - "retry_codes_name": "resource_exhausted_unavailable", - "retry_params_name": "default" - }, - "Rollback": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "RunQuery": { - "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "PartitionQuery": { - "timeout_millis": 300000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "Write": { - "timeout_millis": 86400000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Listen": { - "timeout_millis": 86400000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "ListCollectionIds": { - "timeout_millis": 60000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_internal_unavailable", - "retry_params_name": "default" - }, - "BatchWrite": { - "timeout_millis": 60000, - "retry_codes_name": "resource_exhausted_aborted_unavailable", - "retry_params_name": "default" - }, - "CreateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "resource_exhausted_unavailable", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/firestore_proto_list.json b/owl-bot-staging/v1/src/v1/firestore_proto_list.json deleted file mode 100644 index dcd35e64b..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/firestore/v1/common.proto", - "../../protos/google/firestore/v1/document.proto", - "../../protos/google/firestore/v1/firestore.proto", - "../../protos/google/firestore/v1/query.proto", - "../../protos/google/firestore/v1/write.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 954b6b4de..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.firestore.v1", - "libraryPackage": "@google-cloud/firestore", - "services": { - "Firestore": { - "clients": { - "grpc": { - "libraryClient": "FirestoreClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "BatchWrite": { - "methods": [ - "batchWrite" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "BatchGetDocuments": { - "methods": [ - "batchGetDocuments" - ] - }, - "RunQuery": { - "methods": [ - "runQuery" - ] - }, - "Write": { - "methods": [ - "write" - ] - }, - "Listen": { - "methods": [ - "listen" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery", - "partitionQueryStream", - "partitionQueryAsync" - ] - }, - "ListCollectionIds": { - "methods": [ - "listCollectionIds", - "listCollectionIdsStream", - "listCollectionIdsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FirestoreClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "BatchWrite": { - "methods": [ - "batchWrite" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery", - "partitionQueryStream", - "partitionQueryAsync" - ] - }, - "ListCollectionIds": { - "methods": [ - "listCollectionIds", - "listCollectionIdsStream", - "listCollectionIdsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 80ccfc089..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {FirestoreClient} from './firestore_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index e6b4d6d26..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const firestore = require('@google-cloud/firestore'); - -function main() { - const firestoreClient = new firestore.FirestoreClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 31569a962..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {FirestoreClient} from '@google-cloud/firestore'; - -// check that the client class type name can be used -function doStuffWithFirestoreClient(client: FirestoreClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const firestoreClient = new FirestoreClient(); - doStuffWithFirestoreClient(firestoreClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 8ec452229..000000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_firestore_v1.ts b/owl-bot-staging/v1/test/gapic_firestore_v1.ts deleted file mode 100644 index 74a17f6e9..000000000 --- a/owl-bot-staging/v1/test/gapic_firestore_v1.ts +++ /dev/null @@ -1,1928 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as firestoreModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubServerStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // write something to the stream to trigger transformStub and send the response back to the client - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - return sinon.stub().returns(mockStream); -} - -function stubBidiStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - return sinon.stub().returns(mockStream); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.FirestoreClient', () => { - it('has servicePath', () => { - const servicePath = firestoreModule.v1.FirestoreClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = firestoreModule.v1.FirestoreClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = firestoreModule.v1.FirestoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new firestoreModule.v1.FirestoreClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new firestoreModule.v1.FirestoreClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - await client.initialize(); - assert(client.firestoreStub); - }); - - it('has close method for the initialized client', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.firestoreStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getDocument', () => { - it('invokes getDocument without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDocument without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDocument with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDocument with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.GetDocumentRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocument(request), expectedError); - }); - }); - - describe('updateDocument', () => { - it('invokes updateDocument without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDocument without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateDocument with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDocument with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocument(request), expectedError); - }); - }); - - describe('deleteDocument', () => { - it('invokes deleteDocument without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDocument without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocument( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteDocument with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDocument with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.DeleteDocumentRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocument(request), expectedError); - }); - }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.beginTransaction( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IBeginTransactionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes beginTransaction with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BeginTransactionRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.beginTransaction(request), expectedError); - }); - }); - - describe('commit', () => { - it('invokes commit without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.commit( - request, - (err?: Error|null, result?: protos.google.firestore.v1.ICommitResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes commit with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CommitRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.commit(request), expectedError); - }); - }); - - describe('rollback', () => { - it('invokes rollback without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollback( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rollback with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RollbackRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.rollback(request), expectedError); - }); - }); - - describe('batchWrite', () => { - it('invokes batchWrite without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchWriteResponse()); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchWrite without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchWriteResponse()); - client.innerApiCalls.batchWrite = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchWrite( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IBatchWriteResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchWrite with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchWrite with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchWriteRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchWrite(request), expectedError); - }); - }); - - describe('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.Document()); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createDocument with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDocument with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.CreateDocumentRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocument(request), expectedError); - }); - }); - - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsResponse()); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(expectedResponse); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes batchGetDocuments with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(undefined, expectedError); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes batchGetDocuments with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('runQuery', () => { - it('invokes runQuery without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.RunQueryResponse()); - client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes runQuery with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.runQuery = stubServerStreamingCall(undefined, expectedError); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes runQuery with closed client', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.RunQueryRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('write', () => { - it('invokes write without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.WriteRequest()); - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.WriteResponse()); - client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); - const stream = client.write(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.WriteResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.write as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes write with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.WriteRequest()); - const expectedError = new Error('expected'); - client.innerApiCalls.write = stubBidiStreamingCall(undefined, expectedError); - const stream = client.write(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.WriteResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.write as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('listen', () => { - it('invokes listen without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListenRequest()); - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1.ListenResponse()); - client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); - const stream = client.listen(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.ListenResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listen as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes listen with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListenRequest()); - const expectedError = new Error('expected'); - client.innerApiCalls.listen = stubBidiStreamingCall(undefined, expectedError); - const stream = client.listen(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.ListenResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.listen as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); - const [response] = await client.listDocuments(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDocuments without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDocuments( - request, - (err?: Error|null, result?: protos.google.firestore.v1.IDocument[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDocuments with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDocumentsStream without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1.Document[] = []; - stream.on('data', (response: protos.google.firestore.v1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert.strictEqual( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listDocumentsStream with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1.Document[] = []; - stream.on('data', (response: protos.google.firestore.v1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert.strictEqual( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDocuments without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - generateSampleMessage(new protos.google.firestore.v1.Document()), - ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.v1.IDocument[] = []; - const iterable = client.listDocumentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDocuments with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDocumentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.v1.IDocument[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('partitionQuery', () => { - it('invokes partitionQuery without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - ]; - client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); - const [response] = await client.partitionQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partitionQuery without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - ]; - client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partitionQuery( - request, - (err?: Error|null, result?: protos.google.firestore.v1.ICursor[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes partitionQuery with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partitionQueryStream without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - ]; - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.partitionQueryStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1.Cursor[] = []; - stream.on('data', (response: protos.google.firestore.v1.Cursor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); - assert.strictEqual( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes partitionQueryStream with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.partitionQueryStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1.Cursor[] = []; - stream.on('data', (response: protos.google.firestore.v1.Cursor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); - assert.strictEqual( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with partitionQuery without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1.Cursor()), - ]; - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.v1.ICursor[] = []; - const iterable = client.partitionQueryAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with partitionQuery with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.partitionQueryAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.v1.ICursor[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCollectionIds without error using callback', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCollectionIds( - request, - (err?: Error|null, result?: string[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCollectionIds with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCollectionIdsStream without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCollectionIdsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCollectionIdsStream with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCollectionIdsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCollectionIds without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: string[] = []; - const iterable = client.listCollectionIdsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCollectionIds with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCollectionIdsAsync(request); - await assert.rejects(async () => { - const responses: string[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index 1b321882d..000000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Firestore', - filename: './firestore.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js deleted file mode 100644 index 8849345a0..000000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: 'firestore', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js deleted file mode 100644 index 481c522b0..000000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js deleted file mode 100644 index 494e14786..000000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md deleted file mode 100644 index 02057e6ac..000000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Firestore: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/v1beta1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index 52d715ebe..000000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "firestore", - "version": "0.1.0", - "description": "Firestore client for Node.js", - "repository": "googleapis/nodejs-firestore", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google firestore", - "firestore", - "firestore" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto deleted file mode 100644 index 59c34dd5d..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1beta1; - -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.firestore.v1beta1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; -option ruby_package = "Google::Cloud::Firestore::V1beta1"; - -// A set of field paths on a document. -// Used to restrict a get or update operation on a document to a subset of its -// fields. -// This is different from standard field masks, as this is always scoped to a -// [Document][google.firestore.v1beta1.Document], and takes in account the dynamic nature of [Value][google.firestore.v1beta1.Value]. -message DocumentMask { - // The list of field paths in the mask. See [Document.fields][google.firestore.v1beta1.Document.fields] for a field - // path syntax reference. - repeated string field_paths = 1; -} - -// A precondition on a document, used for conditional operations. -message Precondition { - // The type of precondition. - oneof condition_type { - // When set to `true`, the target document must exist. - // When set to `false`, the target document must not exist. - bool exists = 1; - - // When set, the target document must exist and have been last updated at - // that time. - google.protobuf.Timestamp update_time = 2; - } -} - -// Options for creating a new transaction. -message TransactionOptions { - // Options for a transaction that can be used to read and write documents. - message ReadWrite { - // An optional transaction to retry. - bytes retry_transaction = 1; - } - - // Options for a transaction that can only be used to read documents. - message ReadOnly { - // The consistency mode for this transaction. If not set, defaults to strong - // consistency. - oneof consistency_selector { - // Reads documents at the given time. - // This may not be older than 60 seconds. - google.protobuf.Timestamp read_time = 2; - } - } - - // The mode of the transaction. - oneof mode { - // The transaction can only be used for read operations. - ReadOnly read_only = 2; - - // The transaction can be used for both read and write operations. - ReadWrite read_write = 3; - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto deleted file mode 100644 index 7b9d955b9..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1beta1; - -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/latlng.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.firestore.v1beta1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; -option ruby_package = "Google::Cloud::Firestore::V1beta1"; - -// A Firestore document. -// -// Must not exceed 1 MiB - 4 bytes. -message Document { - // The resource name of the document, for example - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1; - - // The document's fields. - // - // The map keys represent field names. - // - // A simple field name contains only characters `a` to `z`, `A` to `Z`, - // `0` to `9`, or `_`, and must not start with `0` to `9`. For example, - // `foo_bar_17`. - // - // Field names matching the regular expression `__.*__` are reserved. Reserved - // field names are forbidden except in certain documented contexts. The map - // keys, represented as UTF-8, must not exceed 1,500 bytes and cannot be - // empty. - // - // Field paths may be used in other contexts to refer to structured fields - // defined here. For `map_value`, the field path is represented by the simple - // or quoted field names of the containing fields, delimited by `.`. For - // example, the structured field - // `"foo" : { map_value: { "x&y" : { string_value: "hello" }}}` would be - // represented by the field path `foo.x&y`. - // - // Within a field path, a quoted field name starts and ends with `` ` `` and - // may contain any character. Some characters, including `` ` ``, must be - // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and - // `` `bak\`tik` `` represents `` bak`tik ``. - map fields = 2; - - // Output only. The time at which the document was created. - // - // This value increases monotonically when a document is deleted then - // recreated. It can also be compared to values from other documents and - // the `read_time` of a query. - google.protobuf.Timestamp create_time = 3; - - // Output only. The time at which the document was last changed. - // - // This value is initially set to the `create_time` then increases - // monotonically with each change to the document. It can also be - // compared to values from other documents and the `read_time` of a query. - google.protobuf.Timestamp update_time = 4; -} - -// A message that can hold any of the supported value types. -message Value { - // Must have a value set. - oneof value_type { - // A null value. - google.protobuf.NullValue null_value = 11; - - // A boolean value. - bool boolean_value = 1; - - // An integer value. - int64 integer_value = 2; - - // A double value. - double double_value = 3; - - // A timestamp value. - // - // Precise only to microseconds. When stored, any additional precision is - // rounded down. - google.protobuf.Timestamp timestamp_value = 10; - - // A string value. - // - // The string, represented as UTF-8, must not exceed 1 MiB - 89 bytes. - // Only the first 1,500 bytes of the UTF-8 representation are considered by - // queries. - string string_value = 17; - - // A bytes value. - // - // Must not exceed 1 MiB - 89 bytes. - // Only the first 1,500 bytes are considered by queries. - bytes bytes_value = 18; - - // A reference to a document. For example: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string reference_value = 5; - - // A geo point value representing a point on the surface of Earth. - google.type.LatLng geo_point_value = 8; - - // An array value. - // - // Cannot directly contain another array value, though can contain an - // map which contains another array. - ArrayValue array_value = 9; - - // A map value. - MapValue map_value = 6; - } -} - -// An array value. -message ArrayValue { - // Values in the array. - repeated Value values = 1; -} - -// A map value. -message MapValue { - // The map's fields. - // - // The map keys represent field names. Field names matching the regular - // expression `__.*__` are reserved. Reserved field names are forbidden except - // in certain documented contexts. The map keys, represented as UTF-8, must - // not exceed 1,500 bytes and cannot be empty. - map fields = 1; -} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto deleted file mode 100644 index 1fd3a58f3..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/firestore.proto +++ /dev/null @@ -1,900 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/firestore/v1beta1/common.proto"; -import "google/firestore/v1beta1/document.proto"; -import "google/firestore/v1beta1/query.proto"; -import "google/firestore/v1beta1/write.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "FirestoreProto"; -option java_package = "com.google.firestore.v1beta1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; -option ruby_package = "Google::Cloud::Firestore::V1beta1"; - -// Specification of the Firestore API. - -// The Cloud Firestore service. -// -// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL -// document database that simplifies storing, syncing, and querying data for -// your mobile, web, and IoT apps at global scale. Its client libraries provide -// live synchronization and offline support, while its security features and -// integrations with Firebase and Google Cloud Platform (GCP) accelerate -// building truly serverless apps. -service Firestore { - option (google.api.default_host) = "firestore.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/datastore"; - - // Gets a single document. - rpc GetDocument(GetDocumentRequest) returns (Document) { - option (google.api.http) = { - get: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" - }; - } - - // Lists documents. - rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { - option (google.api.http) = { - get: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" - }; - } - - // Updates or inserts a document. - rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { - option (google.api.http) = { - patch: "/v1beta1/{document.name=projects/*/databases/*/documents/*/**}" - body: "document" - }; - option (google.api.method_signature) = "document,update_mask"; - } - - // Deletes a document. - rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1beta1/{name=projects/*/databases/*/documents/*/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets multiple documents. - // - // Documents returned by this method are not guaranteed to be returned in the - // same order that they were requested. - rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:batchGet" - body: "*" - }; - } - - // Starts a new transaction. - rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:beginTransaction" - body: "*" - }; - option (google.api.method_signature) = "database"; - } - - // Commits a transaction, while optionally updating documents. - rpc Commit(CommitRequest) returns (CommitResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:commit" - body: "*" - }; - option (google.api.method_signature) = "database,writes"; - } - - // Rolls back a transaction. - rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:rollback" - body: "*" - }; - option (google.api.method_signature) = "database,transaction"; - } - - // Runs a query. - rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/databases/*/documents}:runQuery" - body: "*" - additional_bindings { - post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:runQuery" - body: "*" - } - }; - } - - // Partitions a query by returning partition cursors that can be used to run - // the query in parallel. The returned partition cursors are split points that - // can be used by RunQuery as starting/end points for the query results. - rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/databases/*/documents}:partitionQuery" - body: "*" - additional_bindings { - post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" - body: "*" - } - }; - } - - // Streams batches of document updates and deletes, in order. - rpc Write(stream WriteRequest) returns (stream WriteResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:write" - body: "*" - }; - } - - // Listens to changes. - rpc Listen(stream ListenRequest) returns (stream ListenResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:listen" - body: "*" - }; - } - - // Lists all the collection IDs underneath a document. - rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/databases/*/documents}:listCollectionIds" - body: "*" - additional_bindings { - post: "/v1beta1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" - body: "*" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Applies a batch of write operations. - // - // The BatchWrite method does not apply the write operations atomically - // and can apply them out of order. Method does not allow more than one write - // per document. Each write succeeds or fails independently. See the - // [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write. - // - // If you require an atomically applied set of writes, use - // [Commit][google.firestore.v1beta1.Firestore.Commit] instead. - rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { - option (google.api.http) = { - post: "/v1beta1/{database=projects/*/databases/*}/documents:batchWrite" - body: "*" - }; - } - - // Creates a new document. - rpc CreateDocument(CreateDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/databases/*/documents/**}/{collection_id}" - body: "document" - }; - } -} - -// The request for [Firestore.GetDocument][google.firestore.v1beta1.Firestore.GetDocument]. -message GetDocumentRequest { - // Required. The resource name of the Document to get. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 2; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads the document in a transaction. - bytes transaction = 3; - - // Reads the version of the document at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 5; - } -} - -// The request for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. -message ListDocumentsRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - // or `messages`. - string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of documents to return. - int32 page_size = 3; - - // The `next_page_token` value returned from a previous List request, if any. - string page_token = 4; - - // The order to sort results by. For example: `priority desc, name`. - string order_by = 6; - - // The fields to return. If not set, returns all fields. - // - // If a document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 7; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents in a transaction. - bytes transaction = 8; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 10; - } - - // If the list should show missing documents. A missing document is a - // document that does not exist but has sub-documents. These documents will - // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1beta1.Document.create_time], - // or [Document.update_time][google.firestore.v1beta1.Document.update_time] set. - // - // Requests with `show_missing` may not specify `where` or - // `order_by`. - bool show_missing = 12; -} - -// The response for [Firestore.ListDocuments][google.firestore.v1beta1.Firestore.ListDocuments]. -message ListDocumentsResponse { - // The Documents found. - repeated Document documents = 1; - - // The next page token. - string next_page_token = 2; -} - -// The request for [Firestore.CreateDocument][google.firestore.v1beta1.Firestore.CreateDocument]. -message CreateDocumentRequest { - // Required. The parent resource. For example: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The client-assigned document ID to use for this document. - // - // Optional. If not specified, an ID will be assigned by the service. - string document_id = 3; - - // Required. The document to create. `name` must not be set. - Document document = 4 [(google.api.field_behavior) = REQUIRED]; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 5; -} - -// The request for [Firestore.UpdateDocument][google.firestore.v1beta1.Firestore.UpdateDocument]. -message UpdateDocumentRequest { - // Required. The updated document. - // Creates the document if it does not already exist. - Document document = 1 [(google.api.field_behavior) = REQUIRED]; - - // The fields to update. - // None of the field paths in the mask may contain a reserved name. - // - // If the document exists on the server and has fields not referenced in the - // mask, they are left unchanged. - // Fields referenced in the mask, but not present in the input document, are - // deleted from the document on the server. - DocumentMask update_mask = 2; - - // The fields to return. If not set, returns all fields. - // - // If the document has a field that is not present in this mask, that field - // will not be returned in the response. - DocumentMask mask = 3; - - // An optional precondition on the document. - // The request will fail if this is set and not met by the target document. - Precondition current_document = 4; -} - -// The request for [Firestore.DeleteDocument][google.firestore.v1beta1.Firestore.DeleteDocument]. -message DeleteDocumentRequest { - // Required. The resource name of the Document to delete. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // An optional precondition on the document. - // The request will fail if this is set and not met by the target document. - Precondition current_document = 2; -} - -// The request for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. -message BatchGetDocumentsRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The names of the documents to retrieve. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // The request will fail if any of the document is not a child resource of the - // given `database`. Duplicate names will be elided. - repeated string documents = 2; - - // The fields to return. If not set, returns all fields. - // - // If a document has a field that is not present in this mask, that field will - // not be returned in the response. - DocumentMask mask = 3; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents in a transaction. - bytes transaction = 4; - - // Starts a new transaction and reads the documents. - // Defaults to a read-only transaction. - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 5; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 7; - } -} - -// The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1beta1.Firestore.BatchGetDocuments]. -message BatchGetDocumentsResponse { - // A single result. - // This can be empty if the server is just returning a transaction. - oneof result { - // A document that was requested. - Document found = 1; - - // A document name that was requested but does not exist. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string missing = 2; - } - - // The transaction that was started as part of this request. - // Will only be set in the first response, and only if - // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1beta1.BatchGetDocumentsRequest.new_transaction] was set in the request. - bytes transaction = 3; - - // The time at which the document was read. - // This may be monotically increasing, in this case the previous documents in - // the result stream are guaranteed not to have changed between their - // read_time and this one. - google.protobuf.Timestamp read_time = 4; -} - -// The request for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. -message BeginTransactionRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The options for the transaction. - // Defaults to a read-write transaction. - TransactionOptions options = 2; -} - -// The response for [Firestore.BeginTransaction][google.firestore.v1beta1.Firestore.BeginTransaction]. -message BeginTransactionResponse { - // The transaction that was started. - bytes transaction = 1; -} - -// The request for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. -message CommitRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The writes to apply. - // - // Always executed atomically and in order. - repeated Write writes = 2; - - // If set, applies all writes in this transaction, and commits it. - bytes transaction = 3; -} - -// The response for [Firestore.Commit][google.firestore.v1beta1.Firestore.Commit]. -message CommitResponse { - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 1; - - // The time at which the commit occurred. Any read with an equal or greater - // `read_time` is guaranteed to see the effects of the commit. - google.protobuf.Timestamp commit_time = 2; -} - -// The request for [Firestore.Rollback][google.firestore.v1beta1.Firestore.Rollback]. -message RollbackRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The transaction to roll back. - bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. -message RunQueryRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to run. - oneof query_type { - // A structured query. - StructuredQuery structured_query = 2; - } - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents in a transaction. - bytes transaction = 5; - - // Starts a new transaction and reads the documents. - // Defaults to a read-only transaction. - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 6; - - // Reads documents as they were at the given time. - // This may not be older than 270 seconds. - google.protobuf.Timestamp read_time = 7; - } -} - -// The response for [Firestore.RunQuery][google.firestore.v1beta1.Firestore.RunQuery]. -message RunQueryResponse { - // The transaction that was started as part of this request. - // Can only be set in the first response, and only if - // [RunQueryRequest.new_transaction][google.firestore.v1beta1.RunQueryRequest.new_transaction] was set in the request. - // If set, no other fields will be set in this response. - bytes transaction = 2; - - // A query result. - // Not set when reporting partial progress. - Document document = 1; - - // The time at which the document was read. This may be monotonically - // increasing; in this case, the previous documents in the result stream are - // guaranteed not to have changed between their `read_time` and this one. - // - // If the query returns no results, a response with `read_time` and no - // `document` will be sent, and this represents the time at which the query - // was run. - google.protobuf.Timestamp read_time = 3; - - // The number of results that have been skipped due to an offset between - // the last response and the current response. - int32 skipped_results = 4; -} - -// The request for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. -message PartitionQueryRequest { - // Required. The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents`. - // Document resource names are not supported; only database resource names - // can be specified. - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The query to partition. - oneof query_type { - // A structured query. - // Query must specify collection with all descendants and be ordered by name - // ascending. Other filters, order bys, limits, offsets, and start/end - // cursors are not supported. - StructuredQuery structured_query = 2; - } - - // The desired maximum number of partition points. - // The partitions may be returned across multiple pages of results. - // The number must be positive. The actual number of partitions - // returned may be fewer. - // - // For example, this may be set to one fewer than the number of parallel - // queries to be run, or in running a data pipeline job, one fewer than the - // number of workers or compute instances available. - int64 partition_count = 3; - - // The `next_page_token` value returned from a previous call to - // PartitionQuery that may be used to get an additional set of results. - // There are no ordering guarantees between sets of results. Thus, using - // multiple sets of results will require merging the different result sets. - // - // For example, two subsequent calls using a page_token may return: - // - // * cursor B, cursor M, cursor Q - // * cursor A, cursor U, cursor W - // - // To obtain a complete result set ordered with respect to the results of the - // query supplied to PartitionQuery, the results sets should be merged: - // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - string page_token = 4; - - // The maximum number of partitions to return in this call, subject to - // `partition_count`. - // - // For example, if `partition_count` = 10 and `page_size` = 8, the first call - // to PartitionQuery will return up to 8 partitions and a `next_page_token` - // 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 response for [Firestore.PartitionQuery][google.firestore.v1beta1.Firestore.PartitionQuery]. -message PartitionQueryResponse { - // Partition results. - // Each partition is a split point that can be used by RunQuery as a starting - // or end point for the query results. The RunQuery requests must be made with - // the same query supplied to this PartitionQuery request. The partition - // cursors will be ordered according to same ordering as the results of the - // query supplied to PartitionQuery. - // - // For example, if a PartitionQuery request returns partition cursors A and B, - // running the following three queries will return the entire result set of - // the original query: - // - // * query, end_at A - // * query, start_at A, end_at B - // * query, start_at B - // - // An empty result may indicate that the query has too few results to be - // partitioned. - repeated Cursor partitions = 1; - - // A page token that may be used to request an additional set of results, up - // to the number specified by `partition_count` in the PartitionQuery request. - // If blank, there are no more results. - string next_page_token = 2; -} - -// The request for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. -// -// The first request creates a stream, or resumes an existing one from a token. -// -// When creating a new stream, the server replies with a response containing -// only an ID and a token, to use in the next request. -// -// When resuming a stream, the server first streams any responses later than the -// given token, then a response containing only an up-to-date token, to use in -// the next request. -message WriteRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - // This is only required in the first message. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The ID of the write stream to resume. - // This may only be set in the first message. When left empty, a new write - // stream will be created. - string stream_id = 2; - - // The writes to apply. - // - // Always executed atomically and in order. - // This must be empty on the first request. - // This may be empty on the last request. - // This must not be empty on all other requests. - repeated Write writes = 3; - - // A stream token that was previously sent by the server. - // - // The client should set this field to the token from the most recent - // [WriteResponse][google.firestore.v1beta1.WriteResponse] it has received. This acknowledges that the client has - // received responses up to this token. After sending this token, earlier - // tokens may not be used anymore. - // - // The server may close the stream if there are too many unacknowledged - // responses. - // - // Leave this field unset when creating a new stream. To resume a stream at - // a specific point, set this field and the `stream_id` field. - // - // Leave this field unset when creating a new stream. - bytes stream_token = 4; - - // Labels associated with this write request. - map labels = 5; -} - -// The response for [Firestore.Write][google.firestore.v1beta1.Firestore.Write]. -message WriteResponse { - // The ID of the stream. - // Only set on the first message, when a new stream was created. - string stream_id = 1; - - // A token that represents the position of this response in the stream. - // This can be used by a client to resume the stream at this point. - // - // This field is always set. - bytes stream_token = 2; - - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 3; - - // The time at which the commit occurred. Any read with an equal or greater - // `read_time` is guaranteed to see the effects of the write. - google.protobuf.Timestamp commit_time = 4; -} - -// A request for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen] -message ListenRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The supported target changes. - oneof target_change { - // A target to add to this stream. - Target add_target = 2; - - // The ID of a target to remove from this stream. - int32 remove_target = 3; - } - - // Labels associated with this target change. - map labels = 4; -} - -// The response for [Firestore.Listen][google.firestore.v1beta1.Firestore.Listen]. -message ListenResponse { - // The supported responses. - oneof response_type { - // Targets have changed. - TargetChange target_change = 2; - - // A [Document][google.firestore.v1beta1.Document] has changed. - DocumentChange document_change = 3; - - // A [Document][google.firestore.v1beta1.Document] has been deleted. - DocumentDelete document_delete = 4; - - // A [Document][google.firestore.v1beta1.Document] has been removed from a target (because it is no longer - // relevant to that target). - DocumentRemove document_remove = 6; - - // A filter to apply to the set of documents previously returned for the - // given target. - // - // Returned when documents may have been removed from the given target, but - // the exact documents are unknown. - ExistenceFilter filter = 5; - } -} - -// A specification of a set of documents to listen to. -message Target { - // A target specified by a set of documents names. - message DocumentsTarget { - // The names of the documents to retrieve. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // The request will fail if any of the document is not a child resource of - // the given `database`. Duplicate names will be elided. - repeated string documents = 2; - } - - // A target specified by a query. - message QueryTarget { - // The parent resource name. In the format: - // `projects/{project_id}/databases/{database_id}/documents` or - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents` or - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1; - - // The query to run. - oneof query_type { - // A structured query. - StructuredQuery structured_query = 2; - } - } - - // The type of target to listen to. - oneof target_type { - // A target specified by a query. - QueryTarget query = 2; - - // A target specified by a set of document names. - DocumentsTarget documents = 3; - } - - // When to start listening. - // - // If not specified, all matching Documents are returned before any - // subsequent changes. - oneof resume_type { - // A resume token from a prior [TargetChange][google.firestore.v1beta1.TargetChange] for an identical target. - // - // Using a resume token with a different target is unsupported and may fail. - bytes resume_token = 4; - - // Start listening after a specific `read_time`. - // - // The client must know the state of matching documents at this time. - google.protobuf.Timestamp read_time = 11; - } - - // The target ID that identifies the target on the stream. Must be a positive - // number and non-zero. - int32 target_id = 5; - - // If the target should be removed once it is current and consistent. - bool once = 6; -} - -// Targets being watched have changed. -message TargetChange { - // The type of change. - enum TargetChangeType { - // No change has occurred. Used only to send an updated `resume_token`. - NO_CHANGE = 0; - - // The targets have been added. - ADD = 1; - - // The targets have been removed. - REMOVE = 2; - - // The targets reflect all changes committed before the targets were added - // to the stream. - // - // This will be sent after or with a `read_time` that is greater than or - // equal to the time at which the targets were added. - // - // Listeners can wait for this change if read-after-write semantics - // are desired. - CURRENT = 3; - - // The targets have been reset, and a new initial state for the targets - // will be returned in subsequent changes. - // - // After the initial state is complete, `CURRENT` will be returned even - // if the target was previously indicated to be `CURRENT`. - RESET = 4; - } - - // The type of change that occurred. - TargetChangeType target_change_type = 1; - - // The target IDs of targets that have changed. - // - // If empty, the change applies to all targets. - // - // The order of the target IDs is not defined. - repeated int32 target_ids = 2; - - // The error that resulted in this change, if applicable. - google.rpc.Status cause = 3; - - // A token that can be used to resume the stream for the given `target_ids`, - // or all targets if `target_ids` is empty. - // - // Not set on every target change. - bytes resume_token = 4; - - // The consistent `read_time` for the given `target_ids` (omitted when the - // target_ids are not at a consistent snapshot). - // - // The stream is guaranteed to send a `read_time` with `target_ids` empty - // whenever the entire stream reaches a new consistent snapshot. ADD, - // CURRENT, and RESET messages are guaranteed to (eventually) result in a - // new consistent snapshot (while NO_CHANGE and REMOVE messages are not). - // - // For a given stream, `read_time` is guaranteed to be monotonically - // increasing. - google.protobuf.Timestamp read_time = 6; -} - -// The request for [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. -message ListCollectionIdsRequest { - // Required. The parent document. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // For example: - // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - string parent = 1 [(google.api.field_behavior) = REQUIRED]; - - // The maximum number of results to return. - int32 page_size = 2; - - // A page token. Must be a value from - // [ListCollectionIdsResponse][google.firestore.v1beta1.ListCollectionIdsResponse]. - string page_token = 3; -} - -// The response from [Firestore.ListCollectionIds][google.firestore.v1beta1.Firestore.ListCollectionIds]. -message ListCollectionIdsResponse { - // The collection ids. - repeated string collection_ids = 1; - - // A page token that may be used to continue the list. - string next_page_token = 2; -} - -// The request for [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. -message BatchWriteRequest { - // Required. The database name. In the format: - // `projects/{project_id}/databases/{database_id}`. - string database = 1 [(google.api.field_behavior) = REQUIRED]; - - // The writes to apply. - // - // Method does not apply writes atomically and does not guarantee ordering. - // Each write succeeds or fails independently. You cannot write to the same - // document more than once per request. - repeated Write writes = 2; - - // Labels associated with this batch write. - map labels = 3; -} - -// The response from [Firestore.BatchWrite][google.firestore.v1beta1.Firestore.BatchWrite]. -message BatchWriteResponse { - // The result of applying the writes. - // - // This i-th write result corresponds to the i-th write in the - // request. - repeated WriteResult write_results = 1; - - // The status of applying the writes. - // - // This i-th write status corresponds to the i-th write in the - // request. - repeated google.rpc.Status status = 2; -} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto deleted file mode 100644 index 0c14777a2..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1beta1; - -import "google/firestore/v1beta1/document.proto"; -import "google/protobuf/wrappers.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "QueryProto"; -option java_package = "com.google.firestore.v1beta1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; -option ruby_package = "Google::Cloud::Firestore::V1beta1"; - -// A Firestore query. -message StructuredQuery { - // A selection of a collection, such as `messages as m1`. - message CollectionSelector { - // The collection ID. - // When set, selects only collections with this ID. - string collection_id = 2; - - // When false, selects only collections that are immediate children of - // the `parent` specified in the containing `RunQueryRequest`. - // When true, selects all descendant collections. - bool all_descendants = 3; - } - - // A filter. - message Filter { - // The type of filter. - oneof filter_type { - // A composite filter. - CompositeFilter composite_filter = 1; - - // A filter on a document field. - FieldFilter field_filter = 2; - - // A filter that takes exactly one argument. - UnaryFilter unary_filter = 3; - } - } - - // A filter that merges multiple other filters using the given operator. - message CompositeFilter { - // A composite filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The results are required to satisfy each of the combined filters. - AND = 1; - } - - // The operator for combining multiple filters. - Operator op = 1; - - // The list of filters to combine. - // Must contain at least one filter. - repeated Filter filters = 2; - } - - // A filter on a specific field. - message FieldFilter { - // A field filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The given `field` is less than the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - LESS_THAN = 1; - - // The given `field` is less than or equal to the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - LESS_THAN_OR_EQUAL = 2; - - // The given `field` is greater than the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - GREATER_THAN = 3; - - // The given `field` is greater than or equal to the given `value`. - // - // Requires: - // - // * That `field` come first in `order_by`. - GREATER_THAN_OR_EQUAL = 4; - - // The given `field` is equal to the given `value`. - EQUAL = 5; - - // The given `field` is not equal to the given `value`. - // - // Requires: - // - // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - NOT_EQUAL = 6; - - // The given `field` is an array that contains the given `value`. - ARRAY_CONTAINS = 7; - - // The given `field` is equal to at least one value in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. - IN = 8; - - // The given `field` is an array that contains any of the values in the - // given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN` or `ARRAY_CONTAINS_ANY` or `NOT_IN`. - ARRAY_CONTAINS_ANY = 9; - - // The value of the `field` is not in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, - // `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - NOT_IN = 10; - } - - // The field to filter by. - FieldReference field = 1; - - // The operator to filter by. - Operator op = 2; - - // The value to compare to. - Value value = 3; - } - - // A filter with a single operand. - message UnaryFilter { - // A unary operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The given `field` is equal to `NaN`. - IS_NAN = 2; - - // The given `field` is equal to `NULL`. - IS_NULL = 3; - - // The given `field` is not equal to `NaN`. - // - // Requires: - // - // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - IS_NOT_NAN = 4; - - // The given `field` is not equal to `NULL`. - // - // Requires: - // - // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. - // * That `field` comes first in the `order_by`. - IS_NOT_NULL = 5; - } - - // The unary operator to apply. - Operator op = 1; - - // The argument to the filter. - oneof operand_type { - // The field to which to apply the operator. - FieldReference field = 2; - } - } - - // A reference to a field, such as `max(messages.time) as max_time`. - message FieldReference { - string field_path = 2; - } - - // An order on a field. - message Order { - // The field to order by. - FieldReference field = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; - } - - // The projection of document's fields to return. - message Projection { - // The fields to return. - // - // If empty, all fields are returned. To only return the name - // of the document, use `['__name__']`. - repeated FieldReference fields = 2; - } - - // A sort direction. - enum Direction { - // Unspecified. - DIRECTION_UNSPECIFIED = 0; - - // Ascending. - ASCENDING = 1; - - // Descending. - DESCENDING = 2; - } - - // The projection to return. - Projection select = 1; - - // The collections to query. - repeated CollectionSelector from = 2; - - // The filter to apply. - Filter where = 3; - - // The order to apply to the query results. - // - // Firestore guarantees a stable ordering through the following rules: - // - // * Any field required to appear in `order_by`, that is not already - // specified in `order_by`, is appended to the order in field name order - // by default. - // * If an order on `__name__` is not specified, it is appended by default. - // - // Fields are appended with the same sort direction as the last order - // specified, or 'ASCENDING' if no order was specified. For example: - // - // * `SELECT * FROM Foo ORDER BY A` becomes - // `SELECT * FROM Foo ORDER BY A, __name__` - // * `SELECT * FROM Foo ORDER BY A DESC` becomes - // `SELECT * FROM Foo ORDER BY A DESC, __name__ DESC` - // * `SELECT * FROM Foo WHERE A > 1` becomes - // `SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__` - repeated Order order_by = 4; - - // A starting point for the query results. - Cursor start_at = 7; - - // A end point for the query results. - Cursor end_at = 8; - - // The number of results to skip. - // - // Applies before limit, but after all other constraints. Must be >= 0 if - // specified. - int32 offset = 6; - - // The maximum number of results to return. - // - // Applies after all other constraints. - // Must be >= 0 if specified. - google.protobuf.Int32Value limit = 5; -} - -// A position in a query result set. -message Cursor { - // The values that represent a position, in the order they appear in - // the order by clause of a query. - // - // Can contain fewer values than specified in the order by clause. - repeated Value values = 1; - - // If the position is just before or just after the given values, relative - // to the sort order defined by the query. - bool before = 2; -} diff --git a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto deleted file mode 100644 index 1ca3c1911..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright 2021 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 -// -// http://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. - -syntax = "proto3"; - -package google.firestore.v1beta1; - -import "google/firestore/v1beta1/common.proto"; -import "google/firestore/v1beta1/document.proto"; -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/firestore/v1beta1;firestore"; -option java_multiple_files = true; -option java_outer_classname = "WriteProto"; -option java_package = "com.google.firestore.v1beta1"; -option objc_class_prefix = "GCFS"; -option php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; -option ruby_package = "Google::Cloud::Firestore::V1beta1"; - -// A write on a document. -message Write { - // The operation to execute. - oneof operation { - // A document to write. - Document update = 1; - - // A document name to delete. In the format: - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - string delete = 2; - - // Applies a transformation to a document. - DocumentTransform transform = 6; - } - - // The fields to update in this write. - // - // This field can be set only when the operation is `update`. - // If the mask is not set for an `update` and the document exists, any - // existing data will be overwritten. - // If the mask is set and the document on the server has fields not covered by - // the mask, they are left unchanged. - // Fields referenced in the mask, but not present in the input document, are - // deleted from the document on the server. - // The field paths in this mask must not contain a reserved field name. - DocumentMask update_mask = 3; - - // The transforms to perform after update. - // - // This field can be set only when the operation is `update`. If present, this - // write is equivalent to performing `update` and `transform` to the same - // document atomically and in order. - repeated DocumentTransform.FieldTransform update_transforms = 7; - - // An optional precondition on the document. - // - // The write will fail if this is set and not met by the target document. - Precondition current_document = 4; -} - -// A transformation of a document. -message DocumentTransform { - // A transformation of a field of the document. - message FieldTransform { - // A value that is calculated by the server. - enum ServerValue { - // Unspecified. This value must not be used. - SERVER_VALUE_UNSPECIFIED = 0; - - // The time at which the server processed the request, with millisecond - // precision. If used on multiple fields (same or different documents) in - // a transaction, all the fields will get the same server timestamp. - REQUEST_TIME = 1; - } - - // The path of the field. See [Document.fields][google.firestore.v1beta1.Document.fields] for the field path syntax - // reference. - string field_path = 1; - - // The transformation to apply on the field. - oneof transform_type { - // Sets the field to the given server value. - ServerValue set_to_server_value = 2; - - // Adds the given value to the field's current value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the given value. - // If either of the given value or the current field value are doubles, - // both values will be interpreted as doubles. Double arithmetic and - // representation of double values follow IEEE 754 semantics. - // If there is positive/negative integer overflow, the field is resolved - // to the largest magnitude positive/negative integer. - Value increment = 3; - - // Sets the field to the maximum of its current value and the given value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the given value. - // If a maximum operation is applied where the field and the input value - // are of mixed types (that is - one is an integer and one is a double) - // the field takes on the type of the larger operand. If the operands are - // equivalent (e.g. 3 and 3.0), the field does not change. - // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and - // zero input value is always the stored value. - // The maximum of any numeric value x and NaN is NaN. - Value maximum = 4; - - // Sets the field to the minimum of its current value and the given value. - // - // This must be an integer or a double value. - // If the field is not an integer or double, or if the field does not yet - // exist, the transformation will set the field to the input value. - // If a minimum operation is applied where the field and the input value - // are of mixed types (that is - one is an integer and one is a double) - // the field takes on the type of the smaller operand. If the operands are - // equivalent (e.g. 3 and 3.0), the field does not change. - // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and - // zero input value is always the stored value. - // The minimum of any numeric value x and NaN is NaN. - Value minimum = 5; - - // Append the given elements in order if they are not already present in - // the current field value. - // If the field is not an array, or if the field does not yet exist, it is - // first set to the empty array. - // - // Equivalent numbers of different types (e.g. 3L and 3.0) are - // considered equal when checking if a value is missing. - // NaN is equal to NaN, and Null is equal to Null. - // If the input contains multiple equivalent values, only the first will - // be considered. - // - // The corresponding transform_result will be the null value. - ArrayValue append_missing_elements = 6; - - // Remove all of the given elements from the array in the field. - // If the field is not an array, or if the field does not yet exist, it is - // set to the empty array. - // - // Equivalent numbers of the different types (e.g. 3L and 3.0) are - // considered equal when deciding whether an element should be removed. - // NaN is equal to NaN, and Null is equal to Null. - // This will remove all equivalent values if there are duplicates. - // - // The corresponding transform_result will be the null value. - ArrayValue remove_all_from_array = 7; - } - } - - // The name of the document to transform. - string document = 1; - - // The list of transformations to apply to the fields of the document, in - // order. - // This must not be empty. - repeated FieldTransform field_transforms = 2; -} - -// The result of applying a write. -message WriteResult { - // The last update time of the document after applying the write. Not set - // after a `delete`. - // - // If the write did not actually change the document, this will be the - // previous update_time. - google.protobuf.Timestamp update_time = 1; - - // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1beta1.DocumentTransform.FieldTransform], in the - // same order. - repeated Value transform_results = 2; -} - -// A [Document][google.firestore.v1beta1.Document] has changed. -// -// May be the result of multiple [writes][google.firestore.v1beta1.Write], including deletes, that -// ultimately resulted in a new value for the [Document][google.firestore.v1beta1.Document]. -// -// Multiple [DocumentChange][google.firestore.v1beta1.DocumentChange] messages may be returned for the same logical -// change, if multiple targets are affected. -message DocumentChange { - // The new state of the [Document][google.firestore.v1beta1.Document]. - // - // If `mask` is set, contains only fields that were updated or added. - Document document = 1; - - // A set of target IDs of targets that match this document. - repeated int32 target_ids = 5; - - // A set of target IDs for targets that no longer match this document. - repeated int32 removed_target_ids = 6; -} - -// A [Document][google.firestore.v1beta1.Document] has been deleted. -// -// May be the result of multiple [writes][google.firestore.v1beta1.Write], including updates, the -// last of which deleted the [Document][google.firestore.v1beta1.Document]. -// -// Multiple [DocumentDelete][google.firestore.v1beta1.DocumentDelete] messages may be returned for the same logical -// delete, if multiple targets are affected. -message DocumentDelete { - // The resource name of the [Document][google.firestore.v1beta1.Document] that was deleted. - string document = 1; - - // A set of target IDs for targets that previously matched this entity. - repeated int32 removed_target_ids = 6; - - // The read timestamp at which the delete was observed. - // - // Greater or equal to the `commit_time` of the delete. - google.protobuf.Timestamp read_time = 4; -} - -// A [Document][google.firestore.v1beta1.Document] has been removed from the view of the targets. -// -// Sent if the document is no longer relevant to a target and is out of view. -// Can be sent instead of a DocumentDelete or a DocumentChange if the server -// can not send the new value of the document. -// -// Multiple [DocumentRemove][google.firestore.v1beta1.DocumentRemove] messages may be returned for the same logical -// write or delete, if multiple targets are affected. -message DocumentRemove { - // The resource name of the [Document][google.firestore.v1beta1.Document] that has gone out of view. - string document = 1; - - // A set of target IDs for targets that previously matched this document. - repeated int32 removed_target_ids = 2; - - // The read timestamp at which the remove was observed. - // - // Greater or equal to the `commit_time` of the change/delete/remove. - google.protobuf.Timestamp read_time = 4; -} - -// A digest of all the documents that match a given target. -message ExistenceFilter { - // The target ID to which this filter applies. - int32 target_id = 1; - - // The total count of documents that match [target_id][google.firestore.v1beta1.ExistenceFilter.target_id]. - // - // If different from the count of documents in the client that match, the - // client must manually determine which documents no longer match the target. - int32 count = 2; -} diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js deleted file mode 100644 index f3a49e484..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js +++ /dev/null @@ -1,90 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_BatchGetDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - */ - // const documents = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If a document has a field that is not present in this mask, that field will - * not be returned in the response. - */ - // const mask = {} - /** - * Reads documents in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBatchGetDocuments() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.batchGetDocuments(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callBatchGetDocuments(); - // [END firestore_v1beta1_generated_Firestore_BatchGetDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js deleted file mode 100644 index 9dd18a64e..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js +++ /dev/null @@ -1,70 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_BatchWrite_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The writes to apply. - * Method does not apply writes atomically and does not guarantee ordering. - * Each write succeeds or fails independently. You cannot write to the same - * document more than once per request. - */ - // const writes = 1234 - /** - * Labels associated with this batch write. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBatchWrite() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.batchWrite(request); - console.log(response); - } - - callBatchWrite(); - // [END firestore_v1beta1_generated_Firestore_BatchWrite_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js deleted file mode 100644 index eea9a9ccc..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_BeginTransaction_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The options for the transaction. - * Defaults to a read-write transaction. - */ - // const options = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callBeginTransaction() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.beginTransaction(request); - console.log(response); - } - - callBeginTransaction(); - // [END firestore_v1beta1_generated_Firestore_BeginTransaction_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js deleted file mode 100644 index 3747286e4..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js +++ /dev/null @@ -1,68 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_Commit_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * The writes to apply. - * Always executed atomically and in order. - */ - // const writes = 1234 - /** - * If set, applies all writes in this transaction, and commits it. - */ - // const transaction = 'Buffer.from('string')' - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callCommit() { - // Construct request - const request = { - database, - }; - - // Run request - const response = await firestoreClient.commit(request); - console.log(response); - } - - callCommit(); - // [END firestore_v1beta1_generated_Firestore_Commit_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js deleted file mode 100644 index ba53875eb..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js +++ /dev/null @@ -1,81 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, collectionId, document) { - // [START firestore_v1beta1_generated_Firestore_CreateDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - */ - // const parent = 'abc123' - /** - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - */ - // const collectionId = 'abc123' - /** - * The client-assigned document ID to use for this document. - * Optional. If not specified, an ID will be assigned by the service. - */ - // const documentId = 'abc123' - /** - * Required. The document to create. `name` must not be set. - */ - // const document = {} - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callCreateDocument() { - // Construct request - const request = { - parent, - collectionId, - document, - }; - - // Run request - const response = await firestoreClient.createDocument(request); - console.log(response); - } - - callCreateDocument(); - // [END firestore_v1beta1_generated_Firestore_CreateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js deleted file mode 100644 index 326f3016a..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1beta1_generated_Firestore_DeleteDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - */ - // const name = 'abc123' - /** - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - */ - // const currentDocument = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callDeleteDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await firestoreClient.deleteDocument(request); - console.log(response); - } - - callDeleteDocument(); - // [END firestore_v1beta1_generated_Firestore_DeleteDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js deleted file mode 100644 index 8de5f8aad..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js +++ /dev/null @@ -1,74 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START firestore_v1beta1_generated_Firestore_GetDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - */ - // const name = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * Reads the document in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Reads the version of the document at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callGetDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await firestoreClient.getDocument(request); - console.log(response); - } - - callGetDocument(); - // [END firestore_v1beta1_generated_Firestore_GetDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js deleted file mode 100644 index 0f258dbc9..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js +++ /dev/null @@ -1,72 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1beta1_generated_Firestore_ListCollectionIds_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * The maximum number of results to return. - */ - // const pageSize = 1234 - /** - * A page token. Must be a value from - * ListCollectionIdsResponse google.firestore.v1beta1.ListCollectionIdsResponse. - */ - // const pageToken = 'abc123' - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListCollectionIds() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await firestoreClient.listCollectionIdsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListCollectionIds(); - // [END firestore_v1beta1_generated_Firestore_ListCollectionIds_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js deleted file mode 100644 index 76924b83a..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js +++ /dev/null @@ -1,107 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, collectionId) { - // [START firestore_v1beta1_generated_Firestore_ListDocuments_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - */ - // const collectionId = 'abc123' - /** - * The maximum number of documents to return. - */ - // const pageSize = 1234 - /** - * The `next_page_token` value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - /** - * The order to sort results by. For example: `priority desc, name`. - */ - // const orderBy = 'abc123' - /** - * The fields to return. If not set, returns all fields. - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * Reads documents in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - /** - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, Document.create_time google.firestore.v1beta1.Document.create_time, - * or Document.update_time google.firestore.v1beta1.Document.update_time set. - * Requests with `show_missing` may not specify `where` or - * `order_by`. - */ - // const showMissing = true - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListDocuments() { - // Construct request - const request = { - parent, - collectionId, - }; - - // Run request - const iterable = await firestoreClient.listDocumentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDocuments(); - // [END firestore_v1beta1_generated_Firestore_ListDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js deleted file mode 100644 index 08248d7a5..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js +++ /dev/null @@ -1,75 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_Listen_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * A target to add to this stream. - */ - // const addTarget = {} - /** - * The ID of a target to remove from this stream. - */ - // const removeTarget = 1234 - /** - * Labels associated with this target change. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callListen() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.listen(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callListen(); - // [END firestore_v1beta1_generated_Firestore_Listen_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js deleted file mode 100644 index ab02276e6..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js +++ /dev/null @@ -1,102 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1beta1_generated_Firestore_PartitionQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - */ - // const parent = 'abc123' - /** - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - */ - // const structuredQuery = {} - /** - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - */ - // const partitionCount = 1234 - /** - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * For example, two subsequent calls using a page_token may return: - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - */ - // const pageToken = 'abc123' - /** - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - */ - // const pageSize = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callPartitionQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await firestoreClient.partitionQueryAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callPartitionQuery(); - // [END firestore_v1beta1_generated_Firestore_PartitionQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js deleted file mode 100644 index ace842326..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database, transaction) { - // [START firestore_v1beta1_generated_Firestore_Rollback_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - */ - // const database = 'abc123' - /** - * Required. The transaction to roll back. - */ - // const transaction = 'Buffer.from('string')' - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRollback() { - // Construct request - const request = { - database, - transaction, - }; - - // Run request - const response = await firestoreClient.rollback(request); - console.log(response); - } - - callRollback(); - // [END firestore_v1beta1_generated_Firestore_Rollback_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js deleted file mode 100644 index 40fe4e2ea..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js +++ /dev/null @@ -1,85 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START firestore_v1beta1_generated_Firestore_RunQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - */ - // const parent = 'abc123' - /** - * A structured query. - */ - // const structuredQuery = {} - /** - * Reads documents in a transaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRunQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const stream = await firestoreClient.runQuery(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callRunQuery(); - // [END firestore_v1beta1_generated_Firestore_RunQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js deleted file mode 100644 index 52b3b5e79..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js +++ /dev/null @@ -1,79 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(document) { - // [START firestore_v1beta1_generated_Firestore_UpdateDocument_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The updated document. - * Creates the document if it does not already exist. - */ - // const document = {} - /** - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - */ - // const updateMask = {} - /** - * The fields to return. If not set, returns all fields. - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - */ - // const mask = {} - /** - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - */ - // const currentDocument = {} - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callUpdateDocument() { - // Construct request - const request = { - document, - }; - - // Run request - const response = await firestoreClient.updateDocument(request); - console.log(response); - } - - callUpdateDocument(); - // [END firestore_v1beta1_generated_Firestore_UpdateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js deleted file mode 100644 index 119d793fe..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js +++ /dev/null @@ -1,95 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(database) { - // [START firestore_v1beta1_generated_Firestore_Write_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * This is only required in the first message. - */ - // const database = 'abc123' - /** - * The ID of the write stream to resume. - * This may only be set in the first message. When left empty, a new write - * stream will be created. - */ - // const streamId = 'abc123' - /** - * The writes to apply. - * Always executed atomically and in order. - * This must be empty on the first request. - * This may be empty on the last request. - * This must not be empty on all other requests. - */ - // const writes = 1234 - /** - * A stream token that was previously sent by the server. - * The client should set this field to the token from the most recent - * WriteResponse google.firestore.v1beta1.WriteResponse it has received. This acknowledges that the client has - * received responses up to this token. After sending this token, earlier - * tokens may not be used anymore. - * The server may close the stream if there are too many unacknowledged - * responses. - * Leave this field unset when creating a new stream. To resume a stream at - * a specific point, set this field and the `stream_id` field. - * Leave this field unset when creating a new stream. - */ - // const streamToken = 'Buffer.from('string')' - /** - * Labels associated with this write request. - */ - // const labels = 1234 - - // Imports the Firestore library - const {FirestoreClient} = require('firestore').v1beta1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callWrite() { - // Construct request - const request = { - database, - }; - - // Run request - const stream = await firestoreClient.write(); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - stream.write(request); - stream.end(); - } - - callWrite(); - // [END firestore_v1beta1_generated_Firestore_Write_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json b/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json deleted file mode 100644 index a3e0b12be..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/snippet_metadata.google.firestore.v1beta1.json +++ /dev/null @@ -1,803 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-firestore", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.firestore.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "firestore_v1beta1_generated_Firestore_GetDocument_async", - "title": "Firestore getDocument Sample", - "origin": "API_DEFINITION", - "description": " Gets a single document.", - "canonical": true, - "file": "firestore.get_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocument", - "fullName": "google.firestore.v1beta1.Firestore.GetDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "mask", - "type": ".google.firestore.v1beta1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1beta1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "GetDocument", - "fullName": "google.firestore.v1beta1.Firestore.GetDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_ListDocuments_async", - "title": "Firestore listDocuments Sample", - "origin": "API_DEFINITION", - "description": " Lists documents.", - "canonical": true, - "file": "firestore.list_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 99, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDocuments", - "fullName": "google.firestore.v1beta1.Firestore.ListDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "collection_id", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "mask", - "type": ".google.firestore.v1beta1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - }, - { - "name": "show_missing", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.firestore.v1beta1.ListDocumentsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "ListDocuments", - "fullName": "google.firestore.v1beta1.Firestore.ListDocuments", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_UpdateDocument_async", - "title": "Firestore updateDocument Sample", - "origin": "API_DEFINITION", - "description": " Updates or inserts a document.", - "canonical": true, - "file": "firestore.update_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocument", - "fullName": "google.firestore.v1beta1.Firestore.UpdateDocument", - "async": true, - "parameters": [ - { - "name": "document", - "type": ".google.firestore.v1beta1.Document" - }, - { - "name": "update_mask", - "type": ".google.firestore.v1beta1.DocumentMask" - }, - { - "name": "mask", - "type": ".google.firestore.v1beta1.DocumentMask" - }, - { - "name": "current_document", - "type": ".google.firestore.v1beta1.Precondition" - } - ], - "resultType": ".google.firestore.v1beta1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "UpdateDocument", - "fullName": "google.firestore.v1beta1.Firestore.UpdateDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_DeleteDocument_async", - "title": "Firestore deleteDocument Sample", - "origin": "API_DEFINITION", - "description": " Deletes a document.", - "canonical": true, - "file": "firestore.delete_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocument", - "fullName": "google.firestore.v1beta1.Firestore.DeleteDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "current_document", - "type": ".google.firestore.v1beta1.Precondition" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "DeleteDocument", - "fullName": "google.firestore.v1beta1.Firestore.DeleteDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_BatchGetDocuments_async", - "title": "Firestore batchGetDocuments Sample", - "origin": "API_DEFINITION", - "description": " Gets multiple documents. Documents returned by this method are not guaranteed to be returned in the same order that they were requested.", - "canonical": true, - "file": "firestore.batch_get_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchGetDocuments", - "fullName": "google.firestore.v1beta1.Firestore.BatchGetDocuments", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "documents", - "type": "TYPE_STRING[]" - }, - { - "name": "mask", - "type": ".google.firestore.v1beta1.DocumentMask" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1beta1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1beta1.BatchGetDocumentsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "BatchGetDocuments", - "fullName": "google.firestore.v1beta1.Firestore.BatchGetDocuments", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_BeginTransaction_async", - "title": "Firestore beginTransaction Sample", - "origin": "API_DEFINITION", - "description": " Starts a new transaction.", - "canonical": true, - "file": "firestore.begin_transaction.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BeginTransaction", - "fullName": "google.firestore.v1beta1.Firestore.BeginTransaction", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.firestore.v1beta1.TransactionOptions" - } - ], - "resultType": ".google.firestore.v1beta1.BeginTransactionResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "BeginTransaction", - "fullName": "google.firestore.v1beta1.Firestore.BeginTransaction", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_Commit_async", - "title": "Firestore commit Sample", - "origin": "API_DEFINITION", - "description": " Commits a transaction, while optionally updating documents.", - "canonical": true, - "file": "firestore.commit.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Commit", - "fullName": "google.firestore.v1beta1.Firestore.Commit", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.firestore.v1beta1.CommitResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "Commit", - "fullName": "google.firestore.v1beta1.Firestore.Commit", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_Rollback_async", - "title": "Firestore rollback Sample", - "origin": "API_DEFINITION", - "description": " Rolls back a transaction.", - "canonical": true, - "file": "firestore.rollback.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Rollback", - "fullName": "google.firestore.v1beta1.Firestore.Rollback", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "Rollback", - "fullName": "google.firestore.v1beta1.Firestore.Rollback", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_RunQuery_async", - "title": "Firestore runQuery Sample", - "origin": "API_DEFINITION", - "description": " Runs a query.", - "canonical": true, - "file": "firestore.run_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunQuery", - "fullName": "google.firestore.v1beta1.Firestore.RunQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_query", - "type": ".google.firestore.v1beta1.StructuredQuery" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1beta1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1beta1.RunQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "RunQuery", - "fullName": "google.firestore.v1beta1.Firestore.RunQuery", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_PartitionQuery_async", - "title": "Firestore partitionQuery Sample", - "origin": "API_DEFINITION", - "description": " Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.", - "canonical": true, - "file": "firestore.partition_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 94, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PartitionQuery", - "fullName": "google.firestore.v1beta1.Firestore.PartitionQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_query", - "type": ".google.firestore.v1beta1.StructuredQuery" - }, - { - "name": "partition_count", - "type": "TYPE_INT64" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.firestore.v1beta1.PartitionQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "PartitionQuery", - "fullName": "google.firestore.v1beta1.Firestore.PartitionQuery", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_Write_async", - "title": "Firestore write Sample", - "origin": "API_DEFINITION", - "description": " Streams batches of document updates and deletes, in order.", - "canonical": true, - "file": "firestore.write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Write", - "fullName": "google.firestore.v1beta1.Firestore.Write", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "stream_id", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "stream_token", - "type": "TYPE_BYTES" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1beta1.WriteResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "Write", - "fullName": "google.firestore.v1beta1.Firestore.Write", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_Listen_async", - "title": "Firestore listen Sample", - "origin": "API_DEFINITION", - "description": " Listens to changes.", - "canonical": true, - "file": "firestore.listen.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Listen", - "fullName": "google.firestore.v1beta1.Firestore.Listen", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "add_target", - "type": ".google.firestore.v1beta1.Target" - }, - { - "name": "remove_target", - "type": "TYPE_INT32" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1beta1.ListenResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "Listen", - "fullName": "google.firestore.v1beta1.Firestore.Listen", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_ListCollectionIds_async", - "title": "Firestore listCollectionIds Sample", - "origin": "API_DEFINITION", - "description": " Lists all the collection IDs underneath a document.", - "canonical": true, - "file": "firestore.list_collection_ids.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListCollectionIds", - "fullName": "google.firestore.v1beta1.Firestore.ListCollectionIds", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.firestore.v1beta1.ListCollectionIdsResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "ListCollectionIds", - "fullName": "google.firestore.v1beta1.Firestore.ListCollectionIds", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_BatchWrite_async", - "title": "Firestore batchWrite Sample", - "origin": "API_DEFINITION", - "description": " Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the [BatchWriteResponse][google.firestore.v1beta1.BatchWriteResponse] for the success status of each write. If you require an atomically applied set of writes, use [Commit][google.firestore.v1beta1.Firestore.Commit] instead.", - "canonical": true, - "file": "firestore.batch_write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchWrite", - "fullName": "google.firestore.v1beta1.Firestore.BatchWrite", - "async": true, - "parameters": [ - { - "name": "database", - "type": "TYPE_STRING" - }, - { - "name": "writes", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.firestore.v1beta1.BatchWriteResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "BatchWrite", - "fullName": "google.firestore.v1beta1.Firestore.BatchWrite", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - }, - { - "regionTag": "firestore_v1beta1_generated_Firestore_CreateDocument_async", - "title": "Firestore createDocument Sample", - "origin": "API_DEFINITION", - "description": " Creates a new document.", - "canonical": true, - "file": "firestore.create_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocument", - "fullName": "google.firestore.v1beta1.Firestore.CreateDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "collection_id", - "type": "TYPE_STRING" - }, - { - "name": "document_id", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.firestore.v1beta1.Document" - }, - { - "name": "mask", - "type": ".google.firestore.v1beta1.DocumentMask" - } - ], - "resultType": ".google.firestore.v1beta1.Document", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1beta1.FirestoreClient" - }, - "method": { - "shortName": "CreateDocument", - "fullName": "google.firestore.v1beta1.Firestore.CreateDocument", - "service": { - "shortName": "Firestore", - "fullName": "google.firestore.v1beta1.Firestore" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts deleted file mode 100644 index 37c81a4b8..000000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const FirestoreClient = v1beta1.FirestoreClient; -type FirestoreClient = v1beta1.FirestoreClient; -export {v1beta1, FirestoreClient}; -export default {v1beta1, FirestoreClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts deleted file mode 100644 index b811e25f7..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts +++ /dev/null @@ -1,1855 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, GoogleError} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import { PassThrough } from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/firestore_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './firestore_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * The Cloud Firestore service. - * - * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL - * document database that simplifies storing, syncing, and querying data for - * your mobile, web, and IoT apps at global scale. Its client libraries provide - * live synchronization and offline support, while its security features and - * integrations with Firebase and Google Cloud Platform (GCP) accelerate - * building truly serverless apps. - * @class - * @memberof v1beta1 - */ -export class FirestoreClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - firestoreStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FirestoreClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof FirestoreClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listDocuments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'), - partitionQuery: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'), - listCollectionIds: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds') - }; - - // Some of the methods on this service provide streaming responses. - // Provide descriptors for these. - this.descriptors.stream = { - batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING), - write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING), - listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.firestore.v1beta1.Firestore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.firestoreStub) { - return this.firestoreStub; - } - - // Put together the "service stub" for - // google.firestore.v1beta1.Firestore. - this.firestoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.firestore.v1beta1.Firestore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.firestore.v1beta1.Firestore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const firestoreStubMethods = - ['getDocument', 'listDocuments', 'updateDocument', 'deleteDocument', 'batchGetDocuments', 'beginTransaction', 'commit', 'rollback', 'runQuery', 'partitionQuery', 'write', 'listen', 'listCollectionIds', 'batchWrite', 'createDocument']; - for (const methodName of firestoreStubMethods) { - const callPromise = this.firestoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - if (methodName in this.descriptors.stream) { - const stream = new PassThrough(); - setImmediate(() => { - stream.emit('error', new GoogleError('The client has already been closed.')); - }); - return stream; - } - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.firestoreStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'firestore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'firestore.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Document to get. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads the document in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads the version of the document at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.get_document.js - * region_tag:firestore_v1beta1_generated_Firestore_GetDocument_async - */ - getDocument( - request?: protos.google.firestore.v1beta1.IGetDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|undefined, {}|undefined - ]>; - getDocument( - request: protos.google.firestore.v1beta1.IGetDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request: protos.google.firestore.v1beta1.IGetDocumentRequest, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request?: protos.google.firestore.v1beta1.IGetDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IGetDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getDocument(request, options, callback); - } -/** - * Updates or inserts a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.firestore.v1beta1.Document} request.document - * Required. The updated document. - * Creates the document if it does not already exist. - * @param {google.firestore.v1beta1.DocumentMask} request.updateMask - * The fields to update. - * None of the field paths in the mask may contain a reserved name. - * - * If the document exists on the server and has fields not referenced in the - * mask, they are left unchanged. - * Fields referenced in the mask, but not present in the input document, are - * deleted from the document on the server. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {google.firestore.v1beta1.Precondition} request.currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.update_document.js - * region_tag:firestore_v1beta1_generated_Firestore_UpdateDocument_async - */ - updateDocument( - request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|undefined, {}|undefined - ]>; - updateDocument( - request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request?: protos.google.firestore.v1beta1.IUpdateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.IUpdateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'document.name': request.document!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateDocument(request, options, callback); - } -/** - * Deletes a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Document to delete. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * @param {google.firestore.v1beta1.Precondition} request.currentDocument - * An optional precondition on the document. - * The request will fail if this is set and not met by the target document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.delete_document.js - * region_tag:firestore_v1beta1_generated_Firestore_DeleteDocument_async - */ - deleteDocument( - request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|undefined, {}|undefined - ]>; - deleteDocument( - request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request?: protos.google.firestore.v1beta1.IDeleteDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IDeleteDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteDocument(request, options, callback); - } -/** - * Starts a new transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {google.firestore.v1beta1.TransactionOptions} request.options - * The options for the transaction. - * Defaults to a read-write transaction. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BeginTransactionResponse]{@link google.firestore.v1beta1.BeginTransactionResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.begin_transaction.js - * region_tag:firestore_v1beta1_generated_Firestore_BeginTransaction_async - */ - beginTransaction( - request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|undefined, {}|undefined - ]>; - beginTransaction( - request: protos.google.firestore.v1beta1.IBeginTransactionRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request: protos.google.firestore.v1beta1.IBeginTransactionRequest, - callback: Callback< - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request?: protos.google.firestore.v1beta1.IBeginTransactionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.IBeginTransactionResponse, - protos.google.firestore.v1beta1.IBeginTransactionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.beginTransaction(request, options, callback); - } -/** - * Commits a transaction, while optionally updating documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {number[]} request.writes - * The writes to apply. - * - * Always executed atomically and in order. - * @param {Buffer} request.transaction - * If set, applies all writes in this transaction, and commits it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CommitResponse]{@link google.firestore.v1beta1.CommitResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.commit.js - * region_tag:firestore_v1beta1_generated_Firestore_Commit_async - */ - commit( - request?: protos.google.firestore.v1beta1.ICommitRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|undefined, {}|undefined - ]>; - commit( - request: protos.google.firestore.v1beta1.ICommitRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request: protos.google.firestore.v1beta1.ICommitRequest, - callback: Callback< - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request?: protos.google.firestore.v1beta1.ICommitRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.ICommitResponse, - protos.google.firestore.v1beta1.ICommitRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.commit(request, options, callback); - } -/** - * Rolls back a transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {Buffer} request.transaction - * Required. The transaction to roll back. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.rollback.js - * region_tag:firestore_v1beta1_generated_Firestore_Rollback_async - */ - rollback( - request?: protos.google.firestore.v1beta1.IRollbackRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|undefined, {}|undefined - ]>; - rollback( - request: protos.google.firestore.v1beta1.IRollbackRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request: protos.google.firestore.v1beta1.IRollbackRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request?: protos.google.firestore.v1beta1.IRollbackRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.firestore.v1beta1.IRollbackRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.rollback(request, options, callback); - } -/** - * Applies a batch of write operations. - * - * The BatchWrite method does not apply the write operations atomically - * and can apply them out of order. Method does not allow more than one write - * per document. Each write succeeds or fails independently. See the - * {@link google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link google.firestore.v1beta1.Firestore.Commit|Commit} instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {number[]} request.writes - * The writes to apply. - * - * Method does not apply writes atomically and does not guarantee ordering. - * Each write succeeds or fails independently. You cannot write to the same - * document more than once per request. - * @param {number[]} request.labels - * Labels associated with this batch write. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BatchWriteResponse]{@link google.firestore.v1beta1.BatchWriteResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.batch_write.js - * region_tag:firestore_v1beta1_generated_Firestore_BatchWrite_async - */ - batchWrite( - request?: protos.google.firestore.v1beta1.IBatchWriteRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|undefined, {}|undefined - ]>; - batchWrite( - request: protos.google.firestore.v1beta1.IBatchWriteRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): void; - batchWrite( - request: protos.google.firestore.v1beta1.IBatchWriteRequest, - callback: Callback< - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): void; - batchWrite( - request?: protos.google.firestore.v1beta1.IBatchWriteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.IBatchWriteResponse, - protos.google.firestore.v1beta1.IBatchWriteRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.batchWrite(request, options, callback); - } -/** - * Creates a new document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource. For example: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. - * @param {string} request.documentId - * The client-assigned document ID to use for this document. - * - * Optional. If not specified, an ID will be assigned by the service. - * @param {google.firestore.v1beta1.Document} request.document - * Required. The document to create. `name` must not be set. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If the document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.firestore.v1beta1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.create_document.js - * region_tag:firestore_v1beta1_generated_Firestore_CreateDocument_async - */ - createDocument( - request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|undefined, {}|undefined - ]>; - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request: protos.google.firestore.v1beta1.ICreateDocumentRequest, - callback: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request?: protos.google.firestore.v1beta1.ICreateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.firestore.v1beta1.IDocument, - protos.google.firestore.v1beta1.ICreateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createDocument(request, options, callback); - } - -/** - * Gets multiple documents. - * - * Documents returned by this method are not guaranteed to be returned in the - * same order that they were requested. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Required. The database name. In the format: - * `projects/{project_id}/databases/{database_id}`. - * @param {string[]} request.documents - * The names of the documents to retrieve. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * The request will fail if any of the document is not a child resource of the - * given `database`. Duplicate names will be elided. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field will - * not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits [BatchGetDocumentsResponse]{@link google.firestore.v1beta1.BatchGetDocumentsResponse} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.batch_get_documents.js - * region_tag:firestore_v1beta1_generated_Firestore_BatchGetDocuments_async - */ - batchGetDocuments( - request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'database': request.database || '', - }); - this.initialize(); - return this.innerApiCalls.batchGetDocuments(request, options); - } - -/** - * Runs a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery - * A structured query. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.firestore.v1beta1.TransactionOptions} request.newTransaction - * Starts a new transaction and reads the documents. - * Defaults to a read-only transaction. - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits [RunQueryResponse]{@link google.firestore.v1beta1.RunQueryResponse} on 'data' event. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.run_query.js - * region_tag:firestore_v1beta1_generated_Firestore_RunQuery_async - */ - runQuery( - request?: protos.google.firestore.v1beta1.IRunQueryRequest, - options?: CallOptions): - gax.CancellableStream{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.runQuery(request, options); - } - -/** - * Streams batches of document updates and deletes, in order. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [WriteRequest]{@link google.firestore.v1beta1.WriteRequest} for write() method, and - * will emit objects representing [WriteResponse]{@link google.firestore.v1beta1.WriteResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.write.js - * region_tag:firestore_v1beta1_generated_Firestore_Write_async - */ - write( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.write(null, options); - } - -/** - * Listens to changes. - * - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which is both readable and writable. It accepts objects - * representing [ListenRequest]{@link google.firestore.v1beta1.ListenRequest} for write() method, and - * will emit objects representing [ListenResponse]{@link google.firestore.v1beta1.ListenResponse} on 'data' event asynchronously. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.listen.js - * region_tag:firestore_v1beta1_generated_Firestore_Listen_async - */ - listen( - options?: CallOptions): - gax.CancellableStream { - this.initialize(); - return this.innerApiCalls.listen(null, options); - } - - /** - * Lists documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Document]{@link google.firestore.v1beta1.Document}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocuments( - request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.IDocument[], - protos.google.firestore.v1beta1.IListDocumentsRequest|null, - protos.google.firestore.v1beta1.IListDocumentsResponse - ]>; - listDocuments( - request: protos.google.firestore.v1beta1.IListDocumentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IListDocumentsRequest, - protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1beta1.IDocument>): void; - listDocuments( - request: protos.google.firestore.v1beta1.IListDocumentsRequest, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IListDocumentsRequest, - protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1beta1.IDocument>): void; - listDocuments( - request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1beta1.IListDocumentsRequest, - protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1beta1.IDocument>, - callback?: PaginationCallback< - protos.google.firestore.v1beta1.IListDocumentsRequest, - protos.google.firestore.v1beta1.IListDocumentsResponse|null|undefined, - protos.google.firestore.v1beta1.IDocument>): - Promise<[ - protos.google.firestore.v1beta1.IDocument[], - protos.google.firestore.v1beta1.IListDocumentsRequest|null, - protos.google.firestore.v1beta1.IListDocumentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listDocuments(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Document]{@link google.firestore.v1beta1.Document} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDocumentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDocumentsStream( - request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDocuments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents` or - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents` or - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {string} request.collectionId - * Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` - * or `messages`. - * @param {number} request.pageSize - * The maximum number of documents to return. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous List request, if any. - * @param {string} request.orderBy - * The order to sort results by. For example: `priority desc, name`. - * @param {google.firestore.v1beta1.DocumentMask} request.mask - * The fields to return. If not set, returns all fields. - * - * If a document has a field that is not present in this mask, that field - * will not be returned in the response. - * @param {Buffer} request.transaction - * Reads documents in a transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * This may not be older than 270 seconds. - * @param {boolean} request.showMissing - * If the list should show missing documents. A missing document is a - * document that does not exist but has sub-documents. These documents will - * be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set. - * - * Requests with `show_missing` may not specify `where` or - * `order_by`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Document]{@link google.firestore.v1beta1.Document}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.list_documents.js - * region_tag:firestore_v1beta1_generated_Firestore_ListDocuments_async - */ - listDocumentsAsync( - request?: protos.google.firestore.v1beta1.IListDocumentsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.asyncIterate( - this.innerApiCalls['listDocuments'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Partitions a query by returning partition cursors that can be used to run - * the query in parallel. The returned partition cursors are split points that - * can be used by RunQuery as starting/end points for the query results. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Cursor]{@link google.firestore.v1beta1.Cursor}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `partitionQueryAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - partitionQuery( - request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.firestore.v1beta1.ICursor[], - protos.google.firestore.v1beta1.IPartitionQueryRequest|null, - protos.google.firestore.v1beta1.IPartitionQueryResponse - ]>; - partitionQuery( - request: protos.google.firestore.v1beta1.IPartitionQueryRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IPartitionQueryRequest, - protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1beta1.ICursor>): void; - partitionQuery( - request: protos.google.firestore.v1beta1.IPartitionQueryRequest, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IPartitionQueryRequest, - protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1beta1.ICursor>): void; - partitionQuery( - request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1beta1.IPartitionQueryRequest, - protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1beta1.ICursor>, - callback?: PaginationCallback< - protos.google.firestore.v1beta1.IPartitionQueryRequest, - protos.google.firestore.v1beta1.IPartitionQueryResponse|null|undefined, - protos.google.firestore.v1beta1.ICursor>): - Promise<[ - protos.google.firestore.v1beta1.ICursor[], - protos.google.firestore.v1beta1.IPartitionQueryRequest|null, - protos.google.firestore.v1beta1.IPartitionQueryResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.partitionQuery(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Cursor]{@link google.firestore.v1beta1.Cursor} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `partitionQueryAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - partitionQueryStream( - request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['partitionQuery']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.partitionQuery.createStream( - this.innerApiCalls.partitionQuery as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `partitionQuery`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource name. In the format: - * `projects/{project_id}/databases/{database_id}/documents`. - * Document resource names are not supported; only database resource names - * can be specified. - * @param {google.firestore.v1beta1.StructuredQuery} request.structuredQuery - * A structured query. - * Query must specify collection with all descendants and be ordered by name - * ascending. Other filters, order bys, limits, offsets, and start/end - * cursors are not supported. - * @param {number} request.partitionCount - * The desired maximum number of partition points. - * The partitions may be returned across multiple pages of results. - * The number must be positive. The actual number of partitions - * returned may be fewer. - * - * For example, this may be set to one fewer than the number of parallel - * queries to be run, or in running a data pipeline job, one fewer than the - * number of workers or compute instances available. - * @param {string} request.pageToken - * The `next_page_token` value returned from a previous call to - * PartitionQuery that may be used to get an additional set of results. - * There are no ordering guarantees between sets of results. Thus, using - * multiple sets of results will require merging the different result sets. - * - * For example, two subsequent calls using a page_token may return: - * - * * cursor B, cursor M, cursor Q - * * cursor A, cursor U, cursor W - * - * To obtain a complete result set ordered with respect to the results of the - * query supplied to PartitionQuery, the results sets should be merged: - * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W - * @param {number} request.pageSize - * The maximum number of partitions to return in this call, subject to - * `partition_count`. - * - * For example, if `partition_count` = 10 and `page_size` = 8, the first call - * to PartitionQuery will return up to 8 partitions and a `next_page_token` - * 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`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Cursor]{@link google.firestore.v1beta1.Cursor}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.partition_query.js - * region_tag:firestore_v1beta1_generated_Firestore_PartitionQuery_async - */ - partitionQueryAsync( - request?: protos.google.firestore.v1beta1.IPartitionQueryRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['partitionQuery']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.partitionQuery.asyncIterate( - this.innerApiCalls['partitionQuery'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Lists all the collection IDs underneath a document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of string. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCollectionIdsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCollectionIds( - request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: CallOptions): - Promise<[ - string[], - protos.google.firestore.v1beta1.IListCollectionIdsRequest|null, - protos.google.firestore.v1beta1.IListCollectionIdsResponse - ]>; - listCollectionIds( - request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IListCollectionIdsRequest, - protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, - string>): void; - listCollectionIds( - request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - callback: PaginationCallback< - protos.google.firestore.v1beta1.IListCollectionIdsRequest, - protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, - string>): void; - listCollectionIds( - request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.firestore.v1beta1.IListCollectionIdsRequest, - protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, - string>, - callback?: PaginationCallback< - protos.google.firestore.v1beta1.IListCollectionIdsRequest, - protos.google.firestore.v1beta1.IListCollectionIdsResponse|null|undefined, - string>): - Promise<[ - string[], - protos.google.firestore.v1beta1.IListCollectionIdsRequest|null, - protos.google.firestore.v1beta1.IListCollectionIdsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listCollectionIds(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing string on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCollectionIdsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listCollectionIdsStream( - request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCollectionIds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectionIds.createStream( - this.innerApiCalls.listCollectionIds as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listCollectionIds`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent document. In the format: - * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - * For example: - * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` - * @param {number} request.pageSize - * The maximum number of results to return. - * @param {string} request.pageToken - * A page token. Must be a value from - * {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * string. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta1/firestore.list_collection_ids.js - * region_tag:firestore_v1beta1_generated_Firestore_ListCollectionIds_async - */ - listCollectionIdsAsync( - request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listCollectionIds']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listCollectionIds.asyncIterate( - this.innerApiCalls['listCollectionIds'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.firestoreStub && !this._terminated) { - return this.firestoreStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json deleted file mode 100644 index b0366d662..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client_config.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "interfaces": { - "google.firestore.v1beta1.Firestore": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "GetDocument": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListDocuments": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteDocument": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchGetDocuments": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BeginTransaction": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "Commit": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Rollback": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RunQuery": { - "timeout_millis": 300000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PartitionQuery": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Write": { - "timeout_millis": 86400000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Listen": { - "timeout_millis": 86400000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListCollectionIds": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchWrite": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateDocument": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json deleted file mode 100644 index fbbd4aecc..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/firestore_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/firestore/v1beta1/common.proto", - "../../protos/google/firestore/v1beta1/document.proto", - "../../protos/google/firestore/v1beta1/firestore.proto", - "../../protos/google/firestore/v1beta1/query.proto", - "../../protos/google/firestore/v1beta1/write.proto" -] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index 45483c761..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.firestore.v1beta1", - "libraryPackage": "firestore", - "services": { - "Firestore": { - "clients": { - "grpc": { - "libraryClient": "FirestoreClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "BatchWrite": { - "methods": [ - "batchWrite" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "BatchGetDocuments": { - "methods": [ - "batchGetDocuments" - ] - }, - "RunQuery": { - "methods": [ - "runQuery" - ] - }, - "Write": { - "methods": [ - "write" - ] - }, - "Listen": { - "methods": [ - "listen" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery", - "partitionQueryStream", - "partitionQueryAsync" - ] - }, - "ListCollectionIds": { - "methods": [ - "listCollectionIds", - "listCollectionIdsStream", - "listCollectionIdsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FirestoreClient", - "rpcs": { - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "BatchWrite": { - "methods": [ - "batchWrite" - ] - }, - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "ListDocuments": { - "methods": [ - "listDocuments", - "listDocumentsStream", - "listDocumentsAsync" - ] - }, - "PartitionQuery": { - "methods": [ - "partitionQuery", - "partitionQueryStream", - "partitionQueryAsync" - ] - }, - "ListCollectionIds": { - "methods": [ - "listCollectionIds", - "listCollectionIdsStream", - "listCollectionIdsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 80ccfc089..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {FirestoreClient} from './firestore_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 0b7733350..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const firestore = require('firestore'); - -function main() { - const firestoreClient = new firestore.FirestoreClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 174db19ce..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {FirestoreClient} from 'firestore'; - -// check that the client class type name can be used -function doStuffWithFirestoreClient(client: FirestoreClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const firestoreClient = new FirestoreClient(); - doStuffWithFirestoreClient(firestoreClient); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts deleted file mode 100644 index 8ec452229..000000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts deleted file mode 100644 index 71f7bf8dc..000000000 --- a/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts +++ /dev/null @@ -1,1928 +0,0 @@ -// 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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as firestoreModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubServerStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // write something to the stream to trigger transformStub and send the response back to the client - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - return sinon.stub().returns(mockStream); -} - -function stubBidiStreamingCall(response?: ResponseType, error?: Error) { - const transformStub = error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - return sinon.stub().returns(mockStream); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta1.FirestoreClient', () => { - it('has servicePath', () => { - const servicePath = firestoreModule.v1beta1.FirestoreClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = firestoreModule.v1beta1.FirestoreClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = firestoreModule.v1beta1.FirestoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new firestoreModule.v1beta1.FirestoreClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - await client.initialize(); - assert(client.firestoreStub); - }); - - it('has close method for the initialized client', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.firestoreStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.firestoreStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getDocument', () => { - it('invokes getDocument without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDocument without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDocument with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - assert((client.innerApiCalls.getDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDocument with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.GetDocumentRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocument(request), expectedError); - }); - }); - - describe('updateDocument', () => { - it('invokes updateDocument without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDocument without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateDocument with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedHeaderRequestParams = "document.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - assert((client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDocument with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.UpdateDocumentRequest()); - request.document = {}; - request.document.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocument(request), expectedError); - }); - }); - - describe('deleteDocument', () => { - it('invokes deleteDocument without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDocument without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocument( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteDocument with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - assert((client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDocument with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.DeleteDocumentRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocument(request), expectedError); - }); - }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.beginTransaction( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IBeginTransactionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes beginTransaction with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BeginTransactionRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.beginTransaction(request), expectedError); - }); - }); - - describe('commit', () => { - it('invokes commit without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.commit( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.ICommitResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes commit with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CommitRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.commit(request), expectedError); - }); - }); - - describe('rollback', () => { - it('invokes rollback without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollback( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rollback with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RollbackRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.rollback(request), expectedError); - }); - }); - - describe('batchWrite', () => { - it('invokes batchWrite without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteResponse()); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchWrite without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteResponse()); - client.innerApiCalls.batchWrite = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchWrite( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IBatchWriteResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchWrite with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - assert((client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchWrite with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchWriteRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchWrite(request), expectedError); - }); - }); - - describe('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.Document()); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createDocument with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - assert((client.innerApiCalls.createDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDocument with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.CreateDocumentRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocument(request), expectedError); - }); - }); - - describe('batchGetDocuments', () => { - it('invokes batchGetDocuments without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsResponse()); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(expectedResponse); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes batchGetDocuments with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedHeaderRequestParams = "database="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchGetDocuments = stubServerStreamingCall(undefined, expectedError); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes batchGetDocuments with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.BatchGetDocumentsRequest()); - request.database = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.BatchGetDocumentsResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('runQuery', () => { - it('invokes runQuery without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryResponse()); - client.innerApiCalls.runQuery = stubServerStreamingCall(expectedResponse); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes runQuery with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.runQuery = stubServerStreamingCall(undefined, expectedError); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions)); - }); - - it('invokes runQuery with closed client', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.RunQueryRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.RunQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - }); - }); - - describe('write', () => { - it('invokes write without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.WriteRequest()); - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.WriteResponse()); - client.innerApiCalls.write = stubBidiStreamingCall(expectedResponse); - const stream = client.write(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.WriteResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.write as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes write with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.WriteRequest()); - const expectedError = new Error('expected'); - client.innerApiCalls.write = stubBidiStreamingCall(undefined, expectedError); - const stream = client.write(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.WriteResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.write as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('listen', () => { - it('invokes listen without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListenRequest()); - const expectedResponse = generateSampleMessage(new protos.google.firestore.v1beta1.ListenResponse()); - client.innerApiCalls.listen = stubBidiStreamingCall(expectedResponse); - const stream = client.listen(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.ListenResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listen as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - - it('invokes listen with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListenRequest()); - const expectedError = new Error('expected'); - client.innerApiCalls.listen = stubBidiStreamingCall(undefined, expectedError); - const stream = client.listen(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1beta1.ListenResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.listen as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); - }); - - describe('listDocuments', () => { - it('invokes listDocuments without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCall(expectedResponse); - const [response] = await client.listDocuments(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDocuments without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - ]; - client.innerApiCalls.listDocuments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDocuments( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.IDocument[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDocuments with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - assert((client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDocumentsStream without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - ]; - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1beta1.Document[] = []; - stream.on('data', (response: protos.google.firestore.v1beta1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert.strictEqual( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listDocumentsStream with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1beta1.Document[] = []; - stream.on('data', (response: protos.google.firestore.v1beta1.Document) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocuments, request)); - assert.strictEqual( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDocuments without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - generateSampleMessage(new protos.google.firestore.v1beta1.Document()), - ]; - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.v1beta1.IDocument[] = []; - const iterable = client.listDocumentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDocuments with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDocumentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.v1beta1.IDocument[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('partitionQuery', () => { - it('invokes partitionQuery without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - ]; - client.innerApiCalls.partitionQuery = stubSimpleCall(expectedResponse); - const [response] = await client.partitionQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partitionQuery without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - ]; - client.innerApiCalls.partitionQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partitionQuery( - request, - (err?: Error|null, result?: protos.google.firestore.v1beta1.ICursor[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes partitionQuery with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - assert((client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partitionQueryStream without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - ]; - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.partitionQueryStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1beta1.Cursor[] = []; - stream.on('data', (response: protos.google.firestore.v1beta1.Cursor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); - assert.strictEqual( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes partitionQueryStream with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.partitionQueryStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.firestore.v1beta1.Cursor[] = []; - stream.on('data', (response: protos.google.firestore.v1beta1.Cursor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.partitionQuery, request)); - assert.strictEqual( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with partitionQuery without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - generateSampleMessage(new protos.google.firestore.v1beta1.Cursor()), - ]; - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.firestore.v1beta1.ICursor[] = []; - const iterable = client.partitionQueryAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with partitionQuery with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.PartitionQueryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.partitionQuery.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.partitionQueryAsync(request); - await assert.rejects(async () => { - const responses: protos.google.firestore.v1beta1.ICursor[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listCollectionIds', () => { - it('invokes listCollectionIds without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCollectionIds without error using callback', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCollectionIds( - request, - (err?: Error|null, result?: string[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listCollectionIds with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - assert((client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listCollectionIdsStream without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCollectionIdsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listCollectionIdsStream with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCollectionIdsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCollectionIds, request)); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCollectionIds without error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: string[] = []; - const iterable = client.listCollectionIdsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listCollectionIds with error', async () => { - const client = new firestoreModule.v1beta1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.firestore.v1beta1.ListCollectionIdsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listCollectionIds.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCollectionIdsAsync(request); - await assert.rejects(async () => { - const responses: string[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js deleted file mode 100644 index 1b321882d..000000000 --- a/owl-bot-staging/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'Firestore', - filename: './firestore.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -};