From 4518b75cf64b4db7cc1bedfbafa9e34cea838c69 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 8 Aug 2023 02:51:59 +0000 Subject: [PATCH 1/5] test: disable retry-request for streaming tests PiperOrigin-RevId: 554648220 Source-Link: https://github.com/googleapis/googleapis/commit/53cd9ad1b48e40cdd44e0c13e96ac0281b32828f Source-Link: https://github.com/googleapis/googleapis-gen/commit/7e8867efbed7dbfe5ef6ec3c2c92a4bce4280f7a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2U4ODY3ZWZiZWQ3ZGJmZTVlZjZlYzNjMmM5MmE0YmNlNDI4MGY3YSJ9 --- 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 + owl-bot-staging/admin/v1/package.json | 58 + .../google/firestore/admin/v1/database.proto | 129 + .../google/firestore/admin/v1/field.proto | 136 + .../firestore/admin/v1/firestore_admin.proto | 512 +++ .../google/firestore/admin/v1/index.proto | 174 + .../google/firestore/admin/v1/location.proto | 31 + .../google/firestore/admin/v1/operation.proto | 223 ++ .../v1/firestore_admin.create_database.js | 75 + .../v1/firestore_admin.create_index.js | 68 + .../v1/firestore_admin.delete_index.js | 62 + .../v1/firestore_admin.export_documents.js | 78 + .../v1/firestore_admin.get_database.js | 62 + .../generated/v1/firestore_admin.get_field.js | 62 + .../generated/v1/firestore_admin.get_index.js | 62 + .../v1/firestore_admin.import_documents.js | 76 + .../v1/firestore_admin.list_databases.js | 62 + .../v1/firestore_admin.list_fields.js | 83 + .../v1/firestore_admin.list_indexes.js | 78 + .../v1/firestore_admin.update_database.js | 66 + .../v1/firestore_admin.update_field.js | 67 + ...et_metadata_google.firestore.admin.v1.json | 595 ++++ owl-bot-staging/admin/v1/src/index.ts | 25 + .../admin/v1/src/v1/firestore_admin_client.ts | 2283 +++++++++++++ .../src/v1/firestore_admin_client_config.json | 92 + .../v1/src/v1/firestore_admin_proto_list.json | 8 + .../admin/v1/src/v1/gapic_metadata.json | 161 + 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 | 2821 +++++++++++++++++ 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/package.json | 58 + .../firestore/v1/aggregation_result.proto | 43 + .../google/firestore/v1/bloom_filter.proto | 73 + .../protos/google/firestore/v1/common.proto | 90 + .../protos/google/firestore/v1/document.proto | 149 + .../google/firestore/v1/firestore.proto | 1094 +++++++ .../v1/protos/google/firestore/v1/query.proto | 506 +++ .../v1/protos/google/firestore/v1/write.proto | 286 ++ .../v1/firestore.batch_get_documents.js | 95 + .../generated/v1/firestore.batch_write.js | 73 + .../v1/firestore.begin_transaction.js | 67 + .../samples/generated/v1/firestore.commit.js | 71 + .../generated/v1/firestore.create_document.js | 85 + .../generated/v1/firestore.delete_document.js | 67 + .../generated/v1/firestore.get_document.js | 79 + .../v1/firestore.list_collection_ids.js | 82 + .../generated/v1/firestore.list_documents.js | 122 + .../samples/generated/v1/firestore.listen.js | 78 + .../generated/v1/firestore.partition_query.js | 112 + .../generated/v1/firestore.rollback.js | 67 + .../v1/firestore.run_aggregation_query.js | 90 + .../generated/v1/firestore.run_query.js | 91 + .../generated/v1/firestore.update_document.js | 82 + .../samples/generated/v1/firestore.write.js | 98 + .../snippet_metadata_google.firestore.v1.json | 867 +++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/firestore_client.ts | 2119 +++++++++++++ .../v1/src/v1/firestore_client_config.json | 121 + .../v1/src/v1/firestore_proto_list.json | 9 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 + 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 | 2423 ++++++++++++++ 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 + owl-bot-staging/v1beta1/package.json | 58 + .../google/firestore/v1beta1/common.proto | 82 + .../google/firestore/v1beta1/document.proto | 149 + .../google/firestore/v1beta1/firestore.proto | 900 ++++++ .../google/firestore/v1beta1/query.proto | 300 ++ .../google/firestore/v1beta1/write.proto | 258 ++ .../v1beta1/firestore.batch_get_documents.js | 93 + .../v1beta1/firestore.batch_write.js | 73 + .../v1beta1/firestore.begin_transaction.js | 67 + .../generated/v1beta1/firestore.commit.js | 71 + .../v1beta1/firestore.create_document.js | 84 + .../v1beta1/firestore.delete_document.js | 67 + .../v1beta1/firestore.get_document.js | 77 + .../v1beta1/firestore.list_collection_ids.js | 75 + .../v1beta1/firestore.list_documents.js | 110 + .../generated/v1beta1/firestore.listen.js | 78 + .../v1beta1/firestore.partition_query.js | 105 + .../generated/v1beta1/firestore.rollback.js | 67 + .../generated/v1beta1/firestore.run_query.js | 88 + .../v1beta1/firestore.update_document.js | 82 + .../generated/v1beta1/firestore.write.js | 98 + ...pet_metadata_google.firestore.v1beta1.json | 803 +++++ owl-bot-staging/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/firestore_client.ts | 1849 +++++++++++ .../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 | 2160 +++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 125 files changed, 26666 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/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_database.js 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/package.json create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto 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_aggregation_query.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/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..d4f03a0df --- /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..4eaf8d13d --- /dev/null +++ b/owl-bot-staging/admin/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/admin/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/admin/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/admin/v1/package.json new file mode 100644 index 000000000..278a732f6 --- /dev/null +++ b/owl-bot-staging/admin/v1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.0", + "jsdoc": "^4.0.2", + "jsdoc-fresh": "^2.0.2", + "jsdoc-region-tag": "^2.0.1", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..5d9b762a1 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto @@ -0,0 +1,129 @@ +// 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.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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. + // + // Mode changes are only allowed if the database is empty. + enum DatabaseType { + // The default value. This value is used if the database type is omitted. + DATABASE_TYPE_UNSPECIFIED = 0; + + // 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 mode is available + // for Cloud Firestore databases. + OPTIMISTIC = 1; + + // Use pessimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. + // + // This is the default setting for Cloud Firestore. + PESSIMISTIC = 2; + + // Use optimistic concurrency control with entity groups by default. + // + // This is the only available mode for Cloud Datastore. + // + // This mode is also available for Cloud Firestore with Datastore Mode but + // is not recommended. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // The type of App Engine integration mode. + enum AppEngineIntegrationMode { + // Not used. + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + + // If an App Engine application exists in the same region as this database, + // App Engine configuration will impact this database. This includes + // disabling of the application & database, as well as disabling writes to + // the database. + ENABLED = 1; + + // Appengine has no affect on the ability of this database to serve + // requests. + DISABLED = 2; + } + + // The resource name of the Database. + // Format: `projects/{project}/databases/{database}` + string name = 1; + + // 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; + + // The App Engine integration mode to use for this database. + AppEngineIntegrationMode app_engine_integration_mode = 19; + + // Output only. The key_prefix for this database. This key_prefix is used, in combination + // with the project id ("~") to construct the + // application id that is returned from the Cloud Datastore APIs in Google App + // Engine first generation runtimes. + // + // This value may be empty in which case the appid to use for URL-encoded keys + // is the project_id (eg: foo instead of v~foo). + string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // This checksum is computed by the server based on the value of other + // fields, and may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + 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..5cd1cd481 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto @@ -0,0 +1,136 @@ +// 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.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/firestore/admin/v1/index.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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; + } + + // The TTL (time-to-live) configuration for documents that have this `Field` + // set. + // Storing a timestamp value into a TTL-enabled field will be treated as + // the document's absolute expiration time. Using any other data type or + // leaving the field absent will disable the TTL for the individual document. + message TtlConfig { + // The state of applying the TTL configuration to all documents. + enum State { + // The state is unspecified or unknown. + STATE_UNSPECIFIED = 0; + + // The TTL is being applied. There is an active long-running operation to + // track the change. Newly written documents will have TTLs applied as + // requested. Requested TTLs on existing documents are still being + // processed. When TTLs on all existing documents have been processed, the + // state will move to 'ACTIVE'. + CREATING = 1; + + // The TTL is active for all documents. + ACTIVE = 2; + + // The TTL configuration could not be enabled for all existing documents. + // Newly written documents will continue to have their TTL applied. + // The LRO returned when last attempting to enable TTL for this `Field` + // has failed, and may have more details. + NEEDS_REPAIR = 3; + } + + // Output only. The state of the TTL configuration. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Required. A field name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` + // + // 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; + + // The TTL configuration for this `Field`. + // Setting or unsetting this will enable or disable the TTL for + // documents that have this `Field`. + TtlConfig ttl_config = 3; +} diff --git a/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..e1faa4dcf --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto @@ -0,0 +1,512 @@ +// Copyright 2023 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/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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" + }; + } + + // Create a database. + rpc CreateDatabase(CreateDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases" + body: "database" + }; + option (google.api.method_signature) = "parent,database,database_id"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "CreateDatabaseMetadata" + }; + } + + // 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 request for +// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]. +message CreateDatabaseRequest { + // 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" + } + ]; + + // Required. The Database to create. + Database database = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. + // + // The value must be set to "(default)". + string database_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata related to the create database operation. +message CreateDatabaseMetadata {} + +// 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..2567da650 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto @@ -0,0 +1,174 @@ +// Copyright 2023 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"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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}" + }; + + // 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; + + // Include all the collections's ancestor in the index. Only available for + // Datastore Mode databases. + COLLECTION_RECURSIVE = 3; + } + + // API Scope defines the APIs (Firestore Native, or Firestore in + // Datastore Mode) that are supported for queries. + enum ApiScope { + // The index can only be used by the Firestore Native query API. + // This is the default. + ANY_API = 0; + + // The index can only be used by the Firestore in Datastore Mode query API. + DATASTORE_MODE_API = 1; + } + + // 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; + } + } + + // 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 API scope supported by this index. + ApiScope api_scope = 5; + + // The fields supported by this index. + // + // For composite indexes, this requires a minimum of 2 and a maximum of 100 + // 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..abf836d92 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto @@ -0,0 +1,31 @@ +// 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.admin.v1; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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..6b0562293 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto @@ -0,0 +1,223 @@ +// 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.admin.v1; + +import "google/firestore/admin/v1/index.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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; + } + + // Information about an TTL configuration change. + message TtlConfigDelta { + // Specifies how the TTL config is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The TTL config is being added. + ADD = 1; + + // The TTL config is being removed. + REMOVE = 2; + } + + // Specifies how the TTL configuration is changing. + ChangeType change_type = 1; + } + + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // 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; + + // Describes the deltas of TTL configuration. + TtlConfigDelta ttl_config_delta = 8; +} + +// 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_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js new file mode 100644 index 000000000..74fe712ca --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js @@ -0,0 +1,75 @@ +// Copyright 2023 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, database, databaseId) { + // [START firestore_v1_generated_FirestoreAdmin_CreateDatabase_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}` + */ + // const parent = 'abc123' + /** + * Required. The Database to create. + */ + // const database = {} + /** + * Required. The ID to use for the database, which will become the final + * component of the database's resource name. + * The value must be set to "(default)". + */ + // const databaseId = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callCreateDatabase() { + // Construct request + const request = { + parent, + database, + databaseId, + }; + + // Run request + const [operation] = await adminClient.createDatabase(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateDatabase(); + // [END firestore_v1_generated_FirestoreAdmin_CreateDatabase_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.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js new file mode 100644 index 000000000..0cf3b60d8 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js @@ -0,0 +1,68 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..d4af852b5 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..a678fbe55 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..14fede7e8 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..f7de563b7 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..749a20bbf --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..5101ecbdc --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js @@ -0,0 +1,76 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..084fc96ef --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..87d562fbe --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js @@ -0,0 +1,83 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..7c1e33448 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..cedf7f52a --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js @@ -0,0 +1,66 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..3d1e1b72f --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..96be9887a --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata_google.firestore.admin.v1.json @@ -0,0 +1,595 @@ +{ + "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": 60, + "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": 70, + "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": 54, + "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": 54, + "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": 54, + "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": 59, + "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": 75, + "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": 70, + "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": 68, + "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_CreateDatabase_async", + "title": "FirestoreAdmin createDatabase Sample", + "origin": "API_DEFINITION", + "description": " Create a database.", + "canonical": true, + "file": "firestore_admin.create_database.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "database", + "type": ".google.firestore.admin.v1.Database" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "CreateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", + "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": 54, + "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": 54, + "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": 58, + "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..53e4b4753 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..1c323f8c2 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts @@ -0,0 +1,2283 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +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'; +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}; + locationsClient: LocationsClient; + 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreAdminClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/databases/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/databases/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 createDatabaseResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Database') as gax.protobuf.Type; + const createDatabaseMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.CreateDatabaseMetadata') 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)), + createDatabase: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createDatabaseResponse.decode.bind(createDatabaseResponse), + createDatabaseMetadata.decode.bind(createDatabaseMetadata)), + 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 = this._gaxModule.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', 'createDatabase', '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._opts.fallback + ); + + 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 {@link protos.google.firestore.admin.v1.Index|Index}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Field|Field}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Database|Database}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.ListDatabasesResponse|ListDatabasesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDatabases(request, options, callback); + } + +/** + * Creates a composite index. This returns a + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a field configuration. Currently, field updates apply only to + * single field index configuration. However, calls to + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateField, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportDocuments, this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Create a database. + * + * @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 {google.firestore.admin.v1.Database} request.database + * Required. The Database to create. + * @param {string} request.databaseId + * Required. The ID to use for the database, which will become the final + * component of the database's resource name. + * + * The value must be set to "(default)". + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async + */ + createDatabase( + request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createDatabase( + request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDatabase(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createDatabase()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async + */ + async checkCreateDatabaseProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createDatabase, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatabase, this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the field configuration and metadata for this database. + * + * Currently, + * {@link protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. 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.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- 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.locationsClient.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..ee5860dbc --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json @@ -0,0 +1,92 @@ +{ + "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" + }, + "CreateDatabase": { + "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..c2af7c470 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json @@ -0,0 +1,161 @@ +{ + "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" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "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" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "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..37fe8fb3f --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..4bafec29c --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..ddf2067ee --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..03b1d8fc7 --- /dev/null +++ b/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts @@ -0,0 +1,2821 @@ +// Copyright 2023 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); + const [response] = await client.deleteIndex(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getField(request), expectedError); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabases(request), expectedError); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createIndex(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateField(request), expectedError); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateField(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('createDatabase', () => { + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); + const [operation] = await client.createDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDatabase( + 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); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(''), 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listIndexes(request), expectedError); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFields(request), expectedError); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + 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..d4f03a0df --- /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..16a892325 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..a76a1c21d --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.0", + "jsdoc": "^4.0.2", + "jsdoc-fresh": "^2.0.2", + "jsdoc-region-tag": "^2.0.1", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto new file mode 100644 index 000000000..05fea5da9 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto @@ -0,0 +1,43 @@ +// Copyright 2023 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/document.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "AggregationResultProto"; +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"; + +// The result of a single bucket from a Firestore aggregation query. +// +// The keys of `aggregate_fields` are the same for all results in an aggregation +// query, unlike document queries which can have different fields present for +// each result. +message AggregationResult { + // The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. + // + // The key is the + // [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias] + // assigned to the aggregation function on input and the size of this map + // equals the number of aggregation functions in the query. + map aggregate_fields = 2; +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto new file mode 100644 index 000000000..c00bb9c17 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto @@ -0,0 +1,73 @@ +// Copyright 2023 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; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "BloomFilterProto"; +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 sequence of bits, encoded in a byte array. +// +// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only +// exception is the last byte, which may store 8 _or fewer_ bits. The `padding` +// defines the number of bits of the last byte to be ignored as "padding". The +// values of these "padding" bits are unspecified and must be ignored. +// +// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. +// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. +// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. +// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. +// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. +// +// The "size" of a `BitSequence` (the number of bits it contains) is calculated +// by this formula: `(bitmap.length * 8) - padding`. +message BitSequence { + // The bytes that encode the bit sequence. + // May have a length of zero. + bytes bitmap = 1; + + // The number of bits of the last byte in `bitmap` to ignore as "padding". + // If the length of `bitmap` is zero, then this value must be `0`. + // Otherwise, this value must be between 0 and 7, inclusive. + int32 padding = 2; +} + +// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). +// +// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit +// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers +// using 2's complement encoding. +// +// These two hash values, named `h1` and `h2`, are then used to compute the +// `hash_count` hash values using the formula, starting at `i=0`: +// +// h(i) = h1 + (i * h2) +// +// These resulting values are then taken modulo the number of bits in the bloom +// filter to get the bits of the bloom filter to test for the given entry. +message BloomFilter { + // The bloom filter data. + BitSequence bits = 1; + + // The number of hashes used by the algorithm. + int32 hash_count = 2; +} 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..2a562aa6e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/common.proto @@ -0,0 +1,90 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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. + // + // Firestore does not allow 3rd party auth requests to create read-write. + // transactions. + 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 must be a microsecond precision timestamp within the past one + // hour, or if Point-in-Time Recovery is enabled, can additionally be a + // whole minute timestamp within the past 7 days. + 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..795200498 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/document.proto @@ -0,0 +1,149 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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..a4447d167 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto @@ -0,0 +1,1094 @@ +// Copyright 2023 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/aggregation_result.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/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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 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: "*" + } + }; + } + + // Runs an aggregation query. + // + // Rather than producing [Document][google.firestore.v1.Document] results like + // [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API + // allows running an aggregation to produce a series of + // [AggregationResult][google.firestore.v1.AggregationResult] server-side. + // + // High-Level Example: + // + // ``` + // -- Return the number of documents in table given a filter. + // SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + // ``` + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (stream RunAggregationQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery" + 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. This method is + // only available via gRPC or WebChannel (not REST). + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. This method is only available via gRPC or WebChannel + // (not REST). + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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]; + + // Optional. The collection ID, relative to `parent`, to list. + // + // For example: `chatrooms` or `messages`. + // + // This is optional, and when not provided, Firestore will list documents + // from all collections under the provided `parent`. + string collection_id = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of documents to return in a single response. + // + // Firestore may return fewer than this value. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListDocuments` response. + // + // Provide this to retrieve the subsequent page. When paginating, all other + // parameters (with the exception of `page_size`) must match the values set + // in the request that generated the page token. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The optional ordering of the documents to return. + // + // For example: `priority desc, __name__ desc`. + // + // This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by] + // used in Firestore queries but in a string representation. When absent, + // documents are ordered based on `__name__ ASC`. + string order_by = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. 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 [(google.api.field_behavior) = OPTIONAL]; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Perform the read as part of an already active transaction. + bytes transaction = 8; + + // Perform the read at the provided time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 10; + } + + // If the list should show missing documents. + // + // A document is missing if it does not exist, but there are sub-documents + // nested underneath it. When true, such missing documents will be returned + // with a key but will not have fields, + // [`create_time`][google.firestore.v1.Document.create_time], or + // [`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; + + // A token to retrieve the next page of documents. + // + // If this field is omitted, there are no subsequent pages. + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryRequest { + // 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 { + // An aggregation query. + StructuredAggregationQuery structured_aggregation_query = 2; + } + + // The consistency mode for the query, defaults to strong consistency. + oneof consistency_selector { + // Run the aggregation within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 4; + + // Starts a new transaction as part of the query, defaulting to read-only. + // + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Executes the query at the given timestamp. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } +} + +// The response for +// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryResponse { + // A single aggregation result. + // + // Not present when reporting partial progress. + AggregationResult result = 1; + + // The transaction that was started as part of this request. + // + // Only present on the first response when the request requested to start + // a new transaction. + bytes transaction = 2; + + // The time at which the aggregate result was computed. This is always + // monotonically increasing; in this case, the previous AggregationResult 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 + // `result` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; +} + +// 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 consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } +} + +// 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 specified, only the matching Documents that have been updated AFTER the + // `resume_token` or `read_time` will be returned. Otherwise, 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; + + // The number of documents that last matched the query at the resume token or + // read time. + // + // This value is only relevant when a `resume_type` is provided. This value + // being present and greater than zero signals that the client wants + // `ExistenceFilter.unchanged_names` to be included in the response. + google.protobuf.Int32Value expected_count = 12; +} + +// 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 consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 4; + } +} + +// 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..4a4919634 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/query.proto @@ -0,0 +1,506 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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; + + // Documents are required to satisfy at least one of the combined filters. + OR = 2; + } + + // 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`, subject to disjunction + // limits. + // * No `NOT_IN` filters in the same query. + 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`, subject to disjunction + // limits. + // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction. + // * No `NOT_IN` filters in the same query. + 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 `OR`, `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 in a document, ex: `stats.operations`. + message FieldReference { + // The relative path of the document being referenced. + // + // Requires: + // + // * Conform to [document field name][google.firestore.v1.Document.fields] + // limitations. + 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; + } + + // Optional sub-set of the fields to return. + // + // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the + // documents returned from a query. When not set, assumes that the caller + // wants all fields returned. + 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 allows callers to provide a full ordering, a partial ordering, or + // no ordering at all. In all cases, Firestore guarantees a stable ordering + // through the following rules: + // + // * The `order_by` is required to reference all fields used with an + // inequality filter. + // * All fields that are required to be in the `order_by` but are not already + // present are appended in lexicographical ordering of the field name. + // * 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: + // + // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` + // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` + // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` + // * `WHERE __name__ > ... AND a > 1` becomes + // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC` + repeated Order order_by = 4; + + // A potential prefix of a position in the result set to start the query at. + // + // The ordering of the result set is based on the `ORDER BY` clause of the + // original query. + // + // ``` + // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; + // ``` + // + // This query's results are ordered by `(b ASC, __name__ ASC)`. + // + // Cursors can reference either the full ordering or a prefix of the location, + // though it cannot reference more fields than what are in the provided + // `ORDER BY`. + // + // Continuing off the example above, attaching the following start cursors + // will have varying impact: + // + // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND + // b > 2 AND __name__ > /k/123`. + // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. + // + // Unlike `OFFSET` which requires scanning over the first N results to skip, + // a start cursor allows the query to begin at a logical position. This + // position is not required to match an actual result, it will scan forward + // from this position to find the next document. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor start_at = 7; + + // A potential prefix of a position in the result set to end the query at. + // + // This is similar to `START_AT` but with it controlling the end position + // rather than the start position. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor end_at = 8; + + // The number of documents to skip before returning the first result. + // + // This applies after the constraints specified by the `WHERE`, `START AT`, & + // `END AT` but before the `LIMIT` clause. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + google.protobuf.Int32Value limit = 5; +} + +// Firestore query for running an aggregation over a +// [StructuredQuery][google.firestore.v1.StructuredQuery]. +message StructuredAggregationQuery { + // Defines an aggregation that produces a single result. + message Aggregation { + // Count of documents that match the query. + // + // The `COUNT(*)` aggregation function operates on the entire document + // so it does not require a field reference. + message Count { + // Optional. Optional constraint on the maximum number of documents to + // count. + // + // This provides a way to set an upper bound on the number of documents + // to scan, limiting latency, and cost. + // + // Unspecified is interpreted as no bound. + // + // High-Level Example: + // + // ``` + // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); + // ``` + // + // Requires: + // + // * Must be greater than zero when present. + google.protobuf.Int64Value up_to = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Sum of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns 0. + // + // * Returns a 64-bit integer if all aggregated numbers are integers and the + // sum result does not overflow. Otherwise, the result is returned as a + // double. Note that even if all the aggregated values are integers, the + // result is returned as a double if it cannot fit within a 64-bit signed + // integer. When this occurs, the returned value will lose precision. + // + // * When underflow occurs, floating-point aggregation is non-deterministic. + // This means that running the same query repeatedly without any changes to + // the underlying values could produce slightly different results each + // time. In those cases, values should be stored as integers over + // floating-point numbers. + message Sum { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // Average of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns `NULL`. + // + // * Always returns the result as a double. + message Avg { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // The type of aggregation to perform, required. + oneof operator { + // Count aggregator. + Count count = 1; + + // Sum aggregator. + Sum sum = 2; + + // Average aggregator. + Avg avg = 3; + } + + // Optional. Optional name of the field to store the result of the + // aggregation into. + // + // If not provided, Firestore will pick a default name following the format + // `field_`. For example: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2), + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) + // OVER ( + // ... + // ); + // ``` + // + // becomes: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2) AS field_1, + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) AS field_2 + // OVER ( + // ... + // ); + // ``` + // + // Requires: + // + // * Must be unique across all aggregation aliases. + // * Conform to [document field name][google.firestore.v1.Document.fields] + // limitations. + string alias = 7 [(google.api.field_behavior) = OPTIONAL]; + } + + // The base query to aggregate over. + oneof query_type { + // Nested structured query. + StructuredQuery structured_query = 1; + } + + // Optional. Series of aggregations to apply over the results of the + // `structured_query`. + // + // Requires: + // + // * A minimum of one and maximum of five aggregations per query. + repeated Aggregation aggregations = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// 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..4b46595ce --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/write.proto @@ -0,0 +1,286 @@ +// Copyright 2023 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/bloom_filter.proto"; +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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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. + // + // The client can use the `unchanged_names` bloom filter to assist with + // this determination by testing ALL the document names against the filter; + // if the document name is NOT in the filter, it means the document no + // longer matches the target. + int32 count = 2; + + // A bloom filter that, despite its name, contains the UTF-8 byte encodings of + // the resource names of ALL the documents that match + // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // + // This bloom filter may be omitted at the server's discretion, such as if it + // is deemed that the client will not make use of it or if it is too + // computationally expensive to calculate or transmit. Clients must gracefully + // handle this field being absent by falling back to the logic used before + // this field existed; that is, re-add the target without a resume token to + // figure out which documents in the client's cache are out of sync. + BloomFilter unchanged_names = 3; +} 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..d1be99f6f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js @@ -0,0 +1,95 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..2180becfe --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js @@ -0,0 +1,73 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * Labels associated with this batch write. + */ + // const labels = [1,2,3,4] + + // 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..fe03086ab --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..70f3ba056 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js @@ -0,0 +1,71 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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..0d1894891 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js @@ -0,0 +1,85 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..bbb97ac7d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..93ad08cc9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js @@ -0,0 +1,79 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..463d68372 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Reads documents as they were at the given time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // 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..a271d2fa3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js @@ -0,0 +1,122 @@ +// Copyright 2023 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_ListDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Optional. The collection ID, relative to `parent`, to list. + * For example: `chatrooms` or `messages`. + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + */ + // const collectionId = 'abc123' + /** + * Optional. The maximum number of documents to return in a single response. + * Firestore may return fewer than this value. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListDocuments` response. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + */ + // const pageToken = 'abc123' + /** + * Optional. The optional ordering of the documents to return. + * For example: `priority desc, __name__ desc`. + * This mirrors the `ORDER BY` google.firestore.v1.StructuredQuery.order_by + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + */ + // const orderBy = 'abc123' + /** + * Optional. 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 = {} + /** + * Perform the read as part of an already active transaction. + */ + // const transaction = Buffer.from('string') + /** + * Perform the read at the provided time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + /** + * If the list should show missing documents. + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * `create_time` google.firestore.v1.Document.create_time, or + * `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, + }; + + // 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..8b38795d5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + + // 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..84acded1b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js @@ -0,0 +1,112 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 + /** + * Reads documents as they were at the given time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // 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..0c75482d1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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_aggregation_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js new file mode 100644 index 000000000..4e3d4f025 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js @@ -0,0 +1,90 @@ +// Copyright 2023 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_RunAggregationQuery_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * An aggregation query. + */ + // const structuredAggregationQuery = {} + /** + * Run the aggregation 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 as part of the query, defaulting to read-only. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Executes the query at the given timestamp. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRunAggregationQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const stream = await firestoreClient.runAggregationQuery(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callRunAggregationQuery(); + // [END firestore_v1_generated_Firestore_RunAggregationQuery_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..2717ffa3b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js @@ -0,0 +1,91 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..904a7cd3a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..8cfd43d15 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.write.js @@ -0,0 +1,98 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..321061a5c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata_google.firestore.v1.json @@ -0,0 +1,867 @@ +{ + "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": 71, + "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": 114, + "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": 74, + "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": 59, + "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": 87, + "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": 59, + "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": 63, + "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": 59, + "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": 83, + "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_RunAggregationQuery_async", + "title": "Firestore runAggregationQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs an aggregation query. Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```", + "canonical": true, + "file": "firestore.run_aggregation_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunAggregationQuery", + "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_aggregation_query", + "type": ".google.firestore.v1.StructuredAggregationQuery" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1.RunAggregationQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "RunAggregationQuery", + "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", + "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": 104, + "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" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "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. This method is only available via gRPC or WebChannel (not REST).", + "canonical": true, + "file": "firestore.write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "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. This method is only available via gRPC or WebChannel (not REST).", + "canonical": true, + "file": "firestore.listen.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "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": 74, + "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" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "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": 65, + "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": 77, + "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..30d0870ac --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..f9ba7d513 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client.ts @@ -0,0 +1,2119 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform, 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 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}; + locationsClient: LocationsClient; + 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // 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(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + runAggregationQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), + listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') + }; + + // 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 = this._gaxModule.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', 'runAggregationQuery', '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 this._gaxModule.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._opts.fallback + ); + + 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.BeginTransactionResponse|BeginTransactionResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.CommitResponse|CommitResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the + * success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link protos.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 {@link protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.RunQueryResponse|RunQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.runQuery(request, options); + } + +/** + * Runs an aggregation query. + * + * Rather than producing {@link protos.google.firestore.v1.Document|Document} results like + * {@link protos.google.firestore.v1.Firestore.RunQuery|Firestore.RunQuery}, this API + * allows running an aggregation to produce a series of + * {@link protos.google.firestore.v1.AggregationResult|AggregationResult} server-side. + * + * High-Level Example: + * + * ``` + * -- Return the number of documents in table given a filter. + * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + * ``` + * + * @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.StructuredAggregationQuery} request.structuredAggregationQuery + * An aggregation query. + * @param {Buffer} request.transaction + * Run the aggregation 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 as part of the query, defaulting to read-only. + * + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Executes the query at the given timestamp. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore.run_aggregation_query.js + * region_tag:firestore_v1_generated_Firestore_RunAggregationQuery_async + */ + runAggregationQuery( + request?: protos.google.firestore.v1.IRunAggregationQueryRequest, + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.runAggregationQuery(request, options); + } + +/** + * Streams batches of document updates and deletes, in order. This method is + * only available via gRPC or WebChannel (not REST). + * + * @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 {@link protos.google.firestore.v1.WriteRequest|WriteRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1.WriteResponse|WriteResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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. This method is only available via gRPC or WebChannel + * (not REST). + * + * @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 {@link protos.google.firestore.v1.ListenRequest|ListenRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1.ListenResponse|ListenResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {}, + 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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. 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.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + + /** + * 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(); + this.locationsClient.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..75487fc9b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client_config.json @@ -0,0 +1,121 @@ +{ + "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" + }, + "RunAggregationQuery": { + "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..5c2cd76e2 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/firestore/v1/aggregation_result.proto", + "../../protos/google/firestore/v1/bloom_filter.proto", + "../../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..4fce00187 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,170 @@ +{ + "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" + ] + }, + "RunAggregationQuery": { + "methods": [ + "runAggregationQuery" + ] + }, + "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..aac58c1b4 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..75ce02186 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..7d85b1cb7 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..598cb8f24 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_firestore_v1.ts @@ -0,0 +1,2423 @@ +// Copyright 2023 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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('runAggregationQuery', () => { + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.RunAggregationQueryResponse() + ); + client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runAggregationQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(undefined, expectedError); + const stream = client.runAggregationQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runAggregationQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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..d4f03a0df --- /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..830c28c2c --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 000000000..4b3c3caa6 --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.0", + "jsdoc": "^4.0.2", + "jsdoc-fresh": "^2.0.2", + "jsdoc-region-tag": "^2.0.1", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..1a18c41bc --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto @@ -0,0 +1,82 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..de192806d --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto @@ -0,0 +1,149 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..047f029e4 --- /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 = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..7d7ef11ce --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto @@ -0,0 +1,300 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..124526a59 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto @@ -0,0 +1,258 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..83d1138bc --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js @@ -0,0 +1,93 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..0e33ee732 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js @@ -0,0 +1,73 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * Labels associated with this batch write. + */ + // const labels = [1,2,3,4] + + // 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..f07a8e5f1 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..9fa52db04 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js @@ -0,0 +1,71 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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..d1b6ef3f7 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js @@ -0,0 +1,84 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..01e5417dd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..ca4c8dcfd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js @@ -0,0 +1,77 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..5d262fe3c --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js @@ -0,0 +1,75 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..ae64fb980 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js @@ -0,0 +1,110 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..9a9e2b838 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + + // 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..808ef53d7 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js @@ -0,0 +1,105 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..7041957dd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..3fd93dada --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js @@ -0,0 +1,88 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..dac3b53dc --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..928b5c292 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js @@ -0,0 +1,98 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..e585b9cfb --- /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": 69, + "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": 102, + "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": 74, + "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": 59, + "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": 85, + "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": 59, + "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": 63, + "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": 59, + "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": 80, + "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": 97, + "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": 90, + "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": 70, + "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": 67, + "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": 65, + "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": 76, + "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..1ef09ee45 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..bb138fc95 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts @@ -0,0 +1,1849 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform, 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), + write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), + listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') + }; + + // 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 = this._gaxModule.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 this._gaxModule.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._opts.fallback + ); + + 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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.BeginTransactionResponse|BeginTransactionResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.CommitResponse|CommitResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link protos.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 {@link protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {@link protos.google.firestore.v1beta1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.RunQueryResponse|RunQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.WriteRequest|WriteRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1beta1.WriteResponse|WriteResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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 {@link protos.google.firestore.v1beta1.ListenRequest|ListenRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1beta1.ListenResponse|ListenResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {}, + 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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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..aac58c1b4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..3dd1ef017 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..08f759d2b --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..b7fa1695c --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts @@ -0,0 +1,2160 @@ +// Copyright 2023 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'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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 852ec09a0a9e54d2cb09bec370ab7b33511bb7c8 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 8 Aug 2023 02:54:57 +0000 Subject: [PATCH 2/5] =?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 --- dev/test/gapic_firestore_v1.ts | 12 +- dev/test/gapic_firestore_v1beta1.ts | 8 +- 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 - owl-bot-staging/admin/v1/package.json | 58 - .../google/firestore/admin/v1/database.proto | 129 - .../google/firestore/admin/v1/field.proto | 136 - .../firestore/admin/v1/firestore_admin.proto | 512 --- .../google/firestore/admin/v1/index.proto | 174 - .../google/firestore/admin/v1/location.proto | 31 - .../google/firestore/admin/v1/operation.proto | 223 -- .../v1/firestore_admin.create_database.js | 75 - .../v1/firestore_admin.create_index.js | 68 - .../v1/firestore_admin.delete_index.js | 62 - .../v1/firestore_admin.export_documents.js | 78 - .../v1/firestore_admin.get_database.js | 62 - .../generated/v1/firestore_admin.get_field.js | 62 - .../generated/v1/firestore_admin.get_index.js | 62 - .../v1/firestore_admin.import_documents.js | 76 - .../v1/firestore_admin.list_databases.js | 62 - .../v1/firestore_admin.list_fields.js | 83 - .../v1/firestore_admin.list_indexes.js | 78 - .../v1/firestore_admin.update_database.js | 66 - .../v1/firestore_admin.update_field.js | 67 - ...et_metadata_google.firestore.admin.v1.json | 595 ---- owl-bot-staging/admin/v1/src/index.ts | 25 - .../admin/v1/src/v1/firestore_admin_client.ts | 2283 ------------- .../src/v1/firestore_admin_client_config.json | 92 - .../v1/src/v1/firestore_admin_proto_list.json | 8 - .../admin/v1/src/v1/gapic_metadata.json | 161 - 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 | 2821 ----------------- 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/package.json | 58 - .../firestore/v1/aggregation_result.proto | 43 - .../google/firestore/v1/bloom_filter.proto | 73 - .../protos/google/firestore/v1/common.proto | 90 - .../protos/google/firestore/v1/document.proto | 149 - .../google/firestore/v1/firestore.proto | 1094 ------- .../v1/protos/google/firestore/v1/query.proto | 506 --- .../v1/protos/google/firestore/v1/write.proto | 286 -- .../v1/firestore.batch_get_documents.js | 95 - .../generated/v1/firestore.batch_write.js | 73 - .../v1/firestore.begin_transaction.js | 67 - .../samples/generated/v1/firestore.commit.js | 71 - .../generated/v1/firestore.create_document.js | 85 - .../generated/v1/firestore.delete_document.js | 67 - .../generated/v1/firestore.get_document.js | 79 - .../v1/firestore.list_collection_ids.js | 82 - .../generated/v1/firestore.list_documents.js | 122 - .../samples/generated/v1/firestore.listen.js | 78 - .../generated/v1/firestore.partition_query.js | 112 - .../generated/v1/firestore.rollback.js | 67 - .../v1/firestore.run_aggregation_query.js | 90 - .../generated/v1/firestore.run_query.js | 91 - .../generated/v1/firestore.update_document.js | 82 - .../samples/generated/v1/firestore.write.js | 98 - .../snippet_metadata_google.firestore.v1.json | 867 ----- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/firestore_client.ts | 2119 ------------- .../v1/src/v1/firestore_client_config.json | 121 - .../v1/src/v1/firestore_proto_list.json | 9 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 - 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 | 2423 -------------- 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 - owl-bot-staging/v1beta1/package.json | 58 - .../google/firestore/v1beta1/common.proto | 82 - .../google/firestore/v1beta1/document.proto | 149 - .../google/firestore/v1beta1/firestore.proto | 900 ------ .../google/firestore/v1beta1/query.proto | 300 -- .../google/firestore/v1beta1/write.proto | 258 -- .../v1beta1/firestore.batch_get_documents.js | 93 - .../v1beta1/firestore.batch_write.js | 73 - .../v1beta1/firestore.begin_transaction.js | 67 - .../generated/v1beta1/firestore.commit.js | 71 - .../v1beta1/firestore.create_document.js | 84 - .../v1beta1/firestore.delete_document.js | 67 - .../v1beta1/firestore.get_document.js | 77 - .../v1beta1/firestore.list_collection_ids.js | 75 - .../v1beta1/firestore.list_documents.js | 110 - .../generated/v1beta1/firestore.listen.js | 78 - .../v1beta1/firestore.partition_query.js | 105 - .../generated/v1beta1/firestore.rollback.js | 67 - .../generated/v1beta1/firestore.run_query.js | 88 - .../v1beta1/firestore.update_document.js | 82 - .../generated/v1beta1/firestore.write.js | 98 - ...pet_metadata_google.firestore.v1beta1.json | 803 ----- owl-bot-staging/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/firestore_client.ts | 1849 ----------- .../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 | 2160 ------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - 127 files changed, 15 insertions(+), 26671 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/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_database.js 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/package.json delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto 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_aggregation_query.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/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/test/gapic_firestore_v1.ts b/dev/test/gapic_firestore_v1.ts index d7d34d909..61fcaac2f 100644 --- a/dev/test/gapic_firestore_v1.ts +++ b/dev/test/gapic_firestore_v1.ts @@ -1420,7 +1420,9 @@ describe('v1.FirestoreClient', () => { request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); - const stream = client.batchGetDocuments(request); + const stream = client.batchGetDocuments(request, { + retryRequestOptions: {noResponseRetries: 0}, + }); const promise = new Promise((resolve, reject) => { stream.on( 'data', @@ -1539,7 +1541,9 @@ describe('v1.FirestoreClient', () => { request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); - const stream = client.runQuery(request); + const stream = client.runQuery(request, { + retryRequestOptions: {noResponseRetries: 0}, + }); const promise = new Promise((resolve, reject) => { stream.on( 'data', @@ -1663,7 +1667,9 @@ describe('v1.FirestoreClient', () => { request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); - const stream = client.runAggregationQuery(request); + const stream = client.runAggregationQuery(request, { + retryRequestOptions: {noResponseRetries: 0}, + }); const promise = new Promise((resolve, reject) => { stream.on( 'data', diff --git a/dev/test/gapic_firestore_v1beta1.ts b/dev/test/gapic_firestore_v1beta1.ts index 89d3a2257..464c284f1 100644 --- a/dev/test/gapic_firestore_v1beta1.ts +++ b/dev/test/gapic_firestore_v1beta1.ts @@ -1426,7 +1426,9 @@ describe('v1beta1.FirestoreClient', () => { request.database = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); - const stream = client.batchGetDocuments(request); + const stream = client.batchGetDocuments(request, { + retryRequestOptions: {noResponseRetries: 0}, + }); const promise = new Promise((resolve, reject) => { stream.on( 'data', @@ -1547,7 +1549,9 @@ describe('v1beta1.FirestoreClient', () => { request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); - const stream = client.runQuery(request); + const stream = client.runQuery(request, { + retryRequestOptions: {noResponseRetries: 0}, + }); const promise = new Promise((resolve, reject) => { stream.on( 'data', 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 d4f03a0df..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 4eaf8d13d..000000000 --- a/owl-bot-staging/admin/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/admin/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/admin/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/admin/v1/package.json deleted file mode 100644 index 278a732f6..000000000 --- a/owl-bot-staging/admin/v1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.0", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^2.0.2", - "jsdoc-region-tag": "^2.0.1", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 5d9b762a1..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto +++ /dev/null @@ -1,129 +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.admin.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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. - // - // Mode changes are only allowed if the database is empty. - enum DatabaseType { - // The default value. This value is used if the database type is omitted. - DATABASE_TYPE_UNSPECIFIED = 0; - - // 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 mode is available - // for Cloud Firestore databases. - OPTIMISTIC = 1; - - // Use pessimistic concurrency control by default. This mode is available - // for Cloud Firestore databases. - // - // This is the default setting for Cloud Firestore. - PESSIMISTIC = 2; - - // Use optimistic concurrency control with entity groups by default. - // - // This is the only available mode for Cloud Datastore. - // - // This mode is also available for Cloud Firestore with Datastore Mode but - // is not recommended. - OPTIMISTIC_WITH_ENTITY_GROUPS = 3; - } - - // The type of App Engine integration mode. - enum AppEngineIntegrationMode { - // Not used. - APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; - - // If an App Engine application exists in the same region as this database, - // App Engine configuration will impact this database. This includes - // disabling of the application & database, as well as disabling writes to - // the database. - ENABLED = 1; - - // Appengine has no affect on the ability of this database to serve - // requests. - DISABLED = 2; - } - - // The resource name of the Database. - // Format: `projects/{project}/databases/{database}` - string name = 1; - - // 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; - - // The App Engine integration mode to use for this database. - AppEngineIntegrationMode app_engine_integration_mode = 19; - - // Output only. The key_prefix for this database. This key_prefix is used, in combination - // with the project id ("~") to construct the - // application id that is returned from the Cloud Datastore APIs in Google App - // Engine first generation runtimes. - // - // This value may be empty in which case the appid to use for URL-encoded keys - // is the project_id (eg: foo instead of v~foo). - string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // This checksum is computed by the server based on the value of other - // fields, and may be sent on update and delete requests to ensure the - // client has an up-to-date value before proceeding. - 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 5cd1cd481..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto +++ /dev/null @@ -1,136 +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.admin.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/firestore/admin/v1/index.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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; - } - - // The TTL (time-to-live) configuration for documents that have this `Field` - // set. - // Storing a timestamp value into a TTL-enabled field will be treated as - // the document's absolute expiration time. Using any other data type or - // leaving the field absent will disable the TTL for the individual document. - message TtlConfig { - // The state of applying the TTL configuration to all documents. - enum State { - // The state is unspecified or unknown. - STATE_UNSPECIFIED = 0; - - // The TTL is being applied. There is an active long-running operation to - // track the change. Newly written documents will have TTLs applied as - // requested. Requested TTLs on existing documents are still being - // processed. When TTLs on all existing documents have been processed, the - // state will move to 'ACTIVE'. - CREATING = 1; - - // The TTL is active for all documents. - ACTIVE = 2; - - // The TTL configuration could not be enabled for all existing documents. - // Newly written documents will continue to have their TTL applied. - // The LRO returned when last attempting to enable TTL for this `Field` - // has failed, and may have more details. - NEEDS_REPAIR = 3; - } - - // Output only. The state of the TTL configuration. - State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Required. A field name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` - // - // 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; - - // The TTL configuration for this `Field`. - // Setting or unsetting this will enable or disable the TTL for - // documents that have this `Field`. - TtlConfig ttl_config = 3; -} diff --git a/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 e1faa4dcf..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto +++ /dev/null @@ -1,512 +0,0 @@ -// Copyright 2023 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/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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" - }; - } - - // Create a database. - rpc CreateDatabase(CreateDatabaseRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/databases" - body: "database" - }; - option (google.api.method_signature) = "parent,database,database_id"; - option (google.longrunning.operation_info) = { - response_type: "Database" - metadata_type: "CreateDatabaseMetadata" - }; - } - - // 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 request for -// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]. -message CreateDatabaseRequest { - // 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" - } - ]; - - // Required. The Database to create. - Database database = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the database, which will become the final - // component of the database's resource name. - // - // The value must be set to "(default)". - string database_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Metadata related to the create database operation. -message CreateDatabaseMetadata {} - -// 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 2567da650..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2023 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"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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}" - }; - - // 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; - - // Include all the collections's ancestor in the index. Only available for - // Datastore Mode databases. - COLLECTION_RECURSIVE = 3; - } - - // API Scope defines the APIs (Firestore Native, or Firestore in - // Datastore Mode) that are supported for queries. - enum ApiScope { - // The index can only be used by the Firestore Native query API. - // This is the default. - ANY_API = 0; - - // The index can only be used by the Firestore in Datastore Mode query API. - DATASTORE_MODE_API = 1; - } - - // 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; - } - } - - // 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 API scope supported by this index. - ApiScope api_scope = 5; - - // The fields supported by this index. - // - // For composite indexes, this requires a minimum of 2 and a maximum of 100 - // 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 abf836d92..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto +++ /dev/null @@ -1,31 +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.admin.v1; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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 6b0562293..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto +++ /dev/null @@ -1,223 +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.admin.v1; - -import "google/firestore/admin/v1/index.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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; - } - - // Information about an TTL configuration change. - message TtlConfigDelta { - // Specifies how the TTL config is changing. - enum ChangeType { - // The type of change is not specified or known. - CHANGE_TYPE_UNSPECIFIED = 0; - - // The TTL config is being added. - ADD = 1; - - // The TTL config is being removed. - REMOVE = 2; - } - - // Specifies how the TTL configuration is changing. - ChangeType change_type = 1; - } - - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // 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; - - // Describes the deltas of TTL configuration. - TtlConfigDelta ttl_config_delta = 8; -} - -// 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_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js deleted file mode 100644 index 74fe712ca..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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, database, databaseId) { - // [START firestore_v1_generated_FirestoreAdmin_CreateDatabase_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}` - */ - // const parent = 'abc123' - /** - * Required. The Database to create. - */ - // const database = {} - /** - * Required. The ID to use for the database, which will become the final - * component of the database's resource name. - * The value must be set to "(default)". - */ - // const databaseId = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callCreateDatabase() { - // Construct request - const request = { - parent, - database, - databaseId, - }; - - // Run request - const [operation] = await adminClient.createDatabase(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateDatabase(); - // [END firestore_v1_generated_FirestoreAdmin_CreateDatabase_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.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js deleted file mode 100644 index 0cf3b60d8..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 d4af852b5..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 a678fbe55..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 14fede7e8..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 f7de563b7..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 749a20bbf..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 5101ecbdc..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 084fc96ef..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 87d562fbe..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 7c1e33448..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 cedf7f52a..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 3d1e1b72f..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 96be9887a..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata_google.firestore.admin.v1.json +++ /dev/null @@ -1,595 +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": 60, - "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": 70, - "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": 54, - "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": 54, - "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": 54, - "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": 59, - "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": 75, - "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": 70, - "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": 68, - "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_CreateDatabase_async", - "title": "FirestoreAdmin createDatabase Sample", - "origin": "API_DEFINITION", - "description": " Create a database.", - "canonical": true, - "file": "firestore_admin.create_database.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "database", - "type": ".google.firestore.admin.v1.Database" - }, - { - "name": "database_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "CreateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", - "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": 54, - "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": 54, - "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": 58, - "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 53e4b4753..000000000 --- a/owl-bot-staging/admin/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 1c323f8c2..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts +++ /dev/null @@ -1,2283 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -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'; -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}; - locationsClient: LocationsClient; - 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreAdminClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/databases/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/databases/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 createDatabaseResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.Database') as gax.protobuf.Type; - const createDatabaseMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.CreateDatabaseMetadata') 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)), - createDatabase: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createDatabaseResponse.decode.bind(createDatabaseResponse), - createDatabaseMetadata.decode.bind(createDatabaseMetadata)), - 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 = this._gaxModule.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', 'createDatabase', '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._opts.fallback - ); - - 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 {@link protos.google.firestore.admin.v1.Index|Index}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Field|Field}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Database|Database}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.ListDatabasesResponse|ListDatabasesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDatabases(request, options, callback); - } - -/** - * Creates a composite index. This returns a - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a field configuration. Currently, field updates apply only to - * single field index configuration. However, calls to - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateField, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportDocuments, this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Create a database. - * - * @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 {google.firestore.admin.v1.Database} request.database - * Required. The Database to create. - * @param {string} request.databaseId - * Required. The ID to use for the database, which will become the final - * component of the database's resource name. - * - * The value must be set to "(default)". - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async - */ - createDatabase( - request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createDatabase( - request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDatabase(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createDatabase()`. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async - */ - async checkCreateDatabaseProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createDatabase, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatabase, this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the field configuration and metadata for this database. - * - * Currently, - * {@link protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @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 {@link google.cloud.location.Location | Location}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. 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.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- 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.locationsClient.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 ee5860dbc..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json +++ /dev/null @@ -1,92 +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" - }, - "CreateDatabase": { - "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 c2af7c470..000000000 --- a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,161 +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" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "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" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "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 37fe8fb3f..000000000 --- a/owl-bot-staging/admin/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 4bafec29c..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 ddf2067ee..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/admin/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 03b1d8fc7..000000000 --- a/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts +++ /dev/null @@ -1,2821 +0,0 @@ -// Copyright 2023 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); - const [response] = await client.deleteIndex(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getField(request), expectedError); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createIndex(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateField(request), expectedError); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateField(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('createDatabase', () => { - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDatabase( - 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); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(''), 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listIndexes(request), expectedError); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFields(request), expectedError); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - 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 d4f03a0df..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 16a892325..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index a76a1c21d..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.0", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^2.0.2", - "jsdoc-region-tag": "^2.0.1", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto deleted file mode 100644 index 05fea5da9..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2023 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/document.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -option java_multiple_files = true; -option java_outer_classname = "AggregationResultProto"; -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"; - -// The result of a single bucket from a Firestore aggregation query. -// -// The keys of `aggregate_fields` are the same for all results in an aggregation -// query, unlike document queries which can have different fields present for -// each result. -message AggregationResult { - // The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. - // - // The key is the - // [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias] - // assigned to the aggregation function on input and the size of this map - // equals the number of aggregation functions in the query. - map aggregate_fields = 2; -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto deleted file mode 100644 index c00bb9c17..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -option java_multiple_files = true; -option java_outer_classname = "BloomFilterProto"; -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 sequence of bits, encoded in a byte array. -// -// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only -// exception is the last byte, which may store 8 _or fewer_ bits. The `padding` -// defines the number of bits of the last byte to be ignored as "padding". The -// values of these "padding" bits are unspecified and must be ignored. -// -// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. -// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. -// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. -// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. -// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. -// -// The "size" of a `BitSequence` (the number of bits it contains) is calculated -// by this formula: `(bitmap.length * 8) - padding`. -message BitSequence { - // The bytes that encode the bit sequence. - // May have a length of zero. - bytes bitmap = 1; - - // The number of bits of the last byte in `bitmap` to ignore as "padding". - // If the length of `bitmap` is zero, then this value must be `0`. - // Otherwise, this value must be between 0 and 7, inclusive. - int32 padding = 2; -} - -// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). -// -// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit -// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers -// using 2's complement encoding. -// -// These two hash values, named `h1` and `h2`, are then used to compute the -// `hash_count` hash values using the formula, starting at `i=0`: -// -// h(i) = h1 + (i * h2) -// -// These resulting values are then taken modulo the number of bits in the bloom -// filter to get the bits of the bloom filter to test for the given entry. -message BloomFilter { - // The bloom filter data. - BitSequence bits = 1; - - // The number of hashes used by the algorithm. - int32 hash_count = 2; -} 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 2a562aa6e..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/common.proto +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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. - // - // Firestore does not allow 3rd party auth requests to create read-write. - // transactions. - 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 must be a microsecond precision timestamp within the past one - // hour, or if Point-in-Time Recovery is enabled, can additionally be a - // whole minute timestamp within the past 7 days. - 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 795200498..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/document.proto +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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 a4447d167..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto +++ /dev/null @@ -1,1094 +0,0 @@ -// Copyright 2023 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/aggregation_result.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/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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 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: "*" - } - }; - } - - // Runs an aggregation query. - // - // Rather than producing [Document][google.firestore.v1.Document] results like - // [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API - // allows running an aggregation to produce a series of - // [AggregationResult][google.firestore.v1.AggregationResult] server-side. - // - // High-Level Example: - // - // ``` - // -- Return the number of documents in table given a filter. - // SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); - // ``` - rpc RunAggregationQuery(RunAggregationQueryRequest) - returns (stream RunAggregationQueryResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery" - 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. This method is - // only available via gRPC or WebChannel (not REST). - rpc Write(stream WriteRequest) returns (stream WriteResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:write" - body: "*" - }; - } - - // Listens to changes. This method is only available via gRPC or WebChannel - // (not REST). - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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]; - - // Optional. The collection ID, relative to `parent`, to list. - // - // For example: `chatrooms` or `messages`. - // - // This is optional, and when not provided, Firestore will list documents - // from all collections under the provided `parent`. - string collection_id = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of documents to return in a single response. - // - // Firestore may return fewer than this value. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListDocuments` response. - // - // Provide this to retrieve the subsequent page. When paginating, all other - // parameters (with the exception of `page_size`) must match the values set - // in the request that generated the page token. - string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The optional ordering of the documents to return. - // - // For example: `priority desc, __name__ desc`. - // - // This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by] - // used in Firestore queries but in a string representation. When absent, - // documents are ordered based on `__name__ ASC`. - string order_by = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. 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 [(google.api.field_behavior) = OPTIONAL]; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Perform the read as part of an already active transaction. - bytes transaction = 8; - - // Perform the read at the provided time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 10; - } - - // If the list should show missing documents. - // - // A document is missing if it does not exist, but there are sub-documents - // nested underneath it. When true, such missing documents will be returned - // with a key but will not have fields, - // [`create_time`][google.firestore.v1.Document.create_time], or - // [`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; - - // A token to retrieve the next page of documents. - // - // If this field is omitted, there are no subsequent pages. - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. -message RunAggregationQueryRequest { - // 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 { - // An aggregation query. - StructuredAggregationQuery structured_aggregation_query = 2; - } - - // The consistency mode for the query, defaults to strong consistency. - oneof consistency_selector { - // Run the aggregation within an already active transaction. - // - // The value here is the opaque transaction ID to execute the query in. - bytes transaction = 4; - - // Starts a new transaction as part of the query, defaulting to read-only. - // - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 5; - - // Executes the query at the given timestamp. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 6; - } -} - -// The response for -// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. -message RunAggregationQueryResponse { - // A single aggregation result. - // - // Not present when reporting partial progress. - AggregationResult result = 1; - - // The transaction that was started as part of this request. - // - // Only present on the first response when the request requested to start - // a new transaction. - bytes transaction = 2; - - // The time at which the aggregate result was computed. This is always - // monotonically increasing; in this case, the previous AggregationResult 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 - // `result` will be sent, and this represents the time at which the query - // was run. - google.protobuf.Timestamp read_time = 3; -} - -// 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 consistency mode for this request. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents as they were at the given time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 6; - } -} - -// 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 specified, only the matching Documents that have been updated AFTER the - // `resume_token` or `read_time` will be returned. Otherwise, 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; - - // The number of documents that last matched the query at the resume token or - // read time. - // - // This value is only relevant when a `resume_type` is provided. This value - // being present and greater than zero signals that the client wants - // `ExistenceFilter.unchanged_names` to be included in the response. - google.protobuf.Int32Value expected_count = 12; -} - -// 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 consistency mode for this request. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents as they were at the given time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 4; - } -} - -// 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 4a4919634..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/query.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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; - - // Documents are required to satisfy at least one of the combined filters. - OR = 2; - } - - // 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`, subject to disjunction - // limits. - // * No `NOT_IN` filters in the same query. - 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`, subject to disjunction - // limits. - // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction. - // * No `NOT_IN` filters in the same query. - 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 `OR`, `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 in a document, ex: `stats.operations`. - message FieldReference { - // The relative path of the document being referenced. - // - // Requires: - // - // * Conform to [document field name][google.firestore.v1.Document.fields] - // limitations. - 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; - } - - // Optional sub-set of the fields to return. - // - // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the - // documents returned from a query. When not set, assumes that the caller - // wants all fields returned. - 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 allows callers to provide a full ordering, a partial ordering, or - // no ordering at all. In all cases, Firestore guarantees a stable ordering - // through the following rules: - // - // * The `order_by` is required to reference all fields used with an - // inequality filter. - // * All fields that are required to be in the `order_by` but are not already - // present are appended in lexicographical ordering of the field name. - // * 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: - // - // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` - // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` - // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` - // * `WHERE __name__ > ... AND a > 1` becomes - // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC` - repeated Order order_by = 4; - - // A potential prefix of a position in the result set to start the query at. - // - // The ordering of the result set is based on the `ORDER BY` clause of the - // original query. - // - // ``` - // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; - // ``` - // - // This query's results are ordered by `(b ASC, __name__ ASC)`. - // - // Cursors can reference either the full ordering or a prefix of the location, - // though it cannot reference more fields than what are in the provided - // `ORDER BY`. - // - // Continuing off the example above, attaching the following start cursors - // will have varying impact: - // - // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND - // b > 2 AND __name__ > /k/123`. - // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. - // - // Unlike `OFFSET` which requires scanning over the first N results to skip, - // a start cursor allows the query to begin at a logical position. This - // position is not required to match an actual result, it will scan forward - // from this position to find the next document. - // - // Requires: - // - // * The number of values cannot be greater than the number of fields - // specified in the `ORDER BY` clause. - Cursor start_at = 7; - - // A potential prefix of a position in the result set to end the query at. - // - // This is similar to `START_AT` but with it controlling the end position - // rather than the start position. - // - // Requires: - // - // * The number of values cannot be greater than the number of fields - // specified in the `ORDER BY` clause. - Cursor end_at = 8; - - // The number of documents to skip before returning the first result. - // - // This applies after the constraints specified by the `WHERE`, `START AT`, & - // `END AT` but before the `LIMIT` clause. - // - // Requires: - // - // * The value must be greater than or equal to zero if specified. - int32 offset = 6; - - // The maximum number of results to return. - // - // Applies after all other constraints. - // - // Requires: - // - // * The value must be greater than or equal to zero if specified. - google.protobuf.Int32Value limit = 5; -} - -// Firestore query for running an aggregation over a -// [StructuredQuery][google.firestore.v1.StructuredQuery]. -message StructuredAggregationQuery { - // Defines an aggregation that produces a single result. - message Aggregation { - // Count of documents that match the query. - // - // The `COUNT(*)` aggregation function operates on the entire document - // so it does not require a field reference. - message Count { - // Optional. Optional constraint on the maximum number of documents to - // count. - // - // This provides a way to set an upper bound on the number of documents - // to scan, limiting latency, and cost. - // - // Unspecified is interpreted as no bound. - // - // High-Level Example: - // - // ``` - // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); - // ``` - // - // Requires: - // - // * Must be greater than zero when present. - google.protobuf.Int64Value up_to = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Sum of the values of the requested field. - // - // * Only numeric values will be aggregated. All non-numeric values - // including `NULL` are skipped. - // - // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math - // follows IEEE-754 standards. - // - // * If the aggregated value set is empty, returns 0. - // - // * Returns a 64-bit integer if all aggregated numbers are integers and the - // sum result does not overflow. Otherwise, the result is returned as a - // double. Note that even if all the aggregated values are integers, the - // result is returned as a double if it cannot fit within a 64-bit signed - // integer. When this occurs, the returned value will lose precision. - // - // * When underflow occurs, floating-point aggregation is non-deterministic. - // This means that running the same query repeatedly without any changes to - // the underlying values could produce slightly different results each - // time. In those cases, values should be stored as integers over - // floating-point numbers. - message Sum { - // The field to aggregate on. - StructuredQuery.FieldReference field = 1; - } - - // Average of the values of the requested field. - // - // * Only numeric values will be aggregated. All non-numeric values - // including `NULL` are skipped. - // - // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math - // follows IEEE-754 standards. - // - // * If the aggregated value set is empty, returns `NULL`. - // - // * Always returns the result as a double. - message Avg { - // The field to aggregate on. - StructuredQuery.FieldReference field = 1; - } - - // The type of aggregation to perform, required. - oneof operator { - // Count aggregator. - Count count = 1; - - // Sum aggregator. - Sum sum = 2; - - // Average aggregator. - Avg avg = 3; - } - - // Optional. Optional name of the field to store the result of the - // aggregation into. - // - // If not provided, Firestore will pick a default name following the format - // `field_`. For example: - // - // ``` - // AGGREGATE - // COUNT_UP_TO(1) AS count_up_to_1, - // COUNT_UP_TO(2), - // COUNT_UP_TO(3) AS count_up_to_3, - // COUNT(*) - // OVER ( - // ... - // ); - // ``` - // - // becomes: - // - // ``` - // AGGREGATE - // COUNT_UP_TO(1) AS count_up_to_1, - // COUNT_UP_TO(2) AS field_1, - // COUNT_UP_TO(3) AS count_up_to_3, - // COUNT(*) AS field_2 - // OVER ( - // ... - // ); - // ``` - // - // Requires: - // - // * Must be unique across all aggregation aliases. - // * Conform to [document field name][google.firestore.v1.Document.fields] - // limitations. - string alias = 7 [(google.api.field_behavior) = OPTIONAL]; - } - - // The base query to aggregate over. - oneof query_type { - // Nested structured query. - StructuredQuery structured_query = 1; - } - - // Optional. Series of aggregations to apply over the results of the - // `structured_query`. - // - // Requires: - // - // * A minimum of one and maximum of five aggregations per query. - repeated Aggregation aggregations = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// 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 4b46595ce..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/write.proto +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright 2023 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/bloom_filter.proto"; -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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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. - // - // The client can use the `unchanged_names` bloom filter to assist with - // this determination by testing ALL the document names against the filter; - // if the document name is NOT in the filter, it means the document no - // longer matches the target. - int32 count = 2; - - // A bloom filter that, despite its name, contains the UTF-8 byte encodings of - // the resource names of ALL the documents that match - // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // - // This bloom filter may be omitted at the server's discretion, such as if it - // is deemed that the client will not make use of it or if it is too - // computationally expensive to calculate or transmit. Clients must gracefully - // handle this field being absent by falling back to the logic used before - // this field existed; that is, re-add the target without a resume token to - // figure out which documents in the client's cache are out of sync. - BloomFilter unchanged_names = 3; -} 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 d1be99f6f..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 2180becfe..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * Labels associated with this batch write. - */ - // const labels = [1,2,3,4] - - // 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 fe03086ab..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 70f3ba056..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 0d1894891..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 bbb97ac7d..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 93ad08cc9..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 463d68372..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Reads documents as they were at the given time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // 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 a271d2fa3..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2023 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_ListDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Optional. The collection ID, relative to `parent`, to list. - * For example: `chatrooms` or `messages`. - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - */ - // const collectionId = 'abc123' - /** - * Optional. The maximum number of documents to return in a single response. - * Firestore may return fewer than this value. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListDocuments` response. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - */ - // const pageToken = 'abc123' - /** - * Optional. The optional ordering of the documents to return. - * For example: `priority desc, __name__ desc`. - * This mirrors the `ORDER BY` google.firestore.v1.StructuredQuery.order_by - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - */ - // const orderBy = 'abc123' - /** - * Optional. 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 = {} - /** - * Perform the read as part of an already active transaction. - */ - // const transaction = Buffer.from('string') - /** - * Perform the read at the provided time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - /** - * If the list should show missing documents. - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * `create_time` google.firestore.v1.Document.create_time, or - * `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, - }; - - // 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 8b38795d5..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - - // 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 84acded1b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 - /** - * Reads documents as they were at the given time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // 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 0c75482d1..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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_aggregation_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js deleted file mode 100644 index 4e3d4f025..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2023 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_RunAggregationQuery_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * An aggregation query. - */ - // const structuredAggregationQuery = {} - /** - * Run the aggregation 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 as part of the query, defaulting to read-only. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Executes the query at the given timestamp. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRunAggregationQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const stream = await firestoreClient.runAggregationQuery(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callRunAggregationQuery(); - // [END firestore_v1_generated_Firestore_RunAggregationQuery_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 2717ffa3b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 904a7cd3a..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 8cfd43d15..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.write.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 321061a5c..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata_google.firestore.v1.json +++ /dev/null @@ -1,867 +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": 71, - "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": 114, - "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": 74, - "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": 59, - "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": 87, - "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": 59, - "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": 63, - "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": 59, - "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": 83, - "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_RunAggregationQuery_async", - "title": "Firestore runAggregationQuery Sample", - "origin": "API_DEFINITION", - "description": " Runs an aggregation query. Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```", - "canonical": true, - "file": "firestore.run_aggregation_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunAggregationQuery", - "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_aggregation_query", - "type": ".google.firestore.v1.StructuredAggregationQuery" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1.RunAggregationQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "RunAggregationQuery", - "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", - "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": 104, - "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" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "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. This method is only available via gRPC or WebChannel (not REST).", - "canonical": true, - "file": "firestore.write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 90, - "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. This method is only available via gRPC or WebChannel (not REST).", - "canonical": true, - "file": "firestore.listen.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "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": 74, - "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" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "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": 65, - "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": 77, - "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 30d0870ac..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 f9ba7d513..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client.ts +++ /dev/null @@ -1,2119 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform, 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 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}; - locationsClient: LocationsClient; - 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // 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(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - runAggregationQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), - listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') - }; - - // 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 = this._gaxModule.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', 'runAggregationQuery', '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 this._gaxModule.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._opts.fallback - ); - - 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.BeginTransactionResponse|BeginTransactionResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.CommitResponse|CommitResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the - * success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link protos.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 {@link protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.RunQueryResponse|RunQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.runQuery(request, options); - } - -/** - * Runs an aggregation query. - * - * Rather than producing {@link protos.google.firestore.v1.Document|Document} results like - * {@link protos.google.firestore.v1.Firestore.RunQuery|Firestore.RunQuery}, this API - * allows running an aggregation to produce a series of - * {@link protos.google.firestore.v1.AggregationResult|AggregationResult} server-side. - * - * High-Level Example: - * - * ``` - * -- Return the number of documents in table given a filter. - * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); - * ``` - * - * @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.StructuredAggregationQuery} request.structuredAggregationQuery - * An aggregation query. - * @param {Buffer} request.transaction - * Run the aggregation 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 as part of the query, defaulting to read-only. - * - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Executes the query at the given timestamp. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore.run_aggregation_query.js - * region_tag:firestore_v1_generated_Firestore_RunAggregationQuery_async - */ - runAggregationQuery( - request?: protos.google.firestore.v1.IRunAggregationQueryRequest, - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.runAggregationQuery(request, options); - } - -/** - * Streams batches of document updates and deletes, in order. This method is - * only available via gRPC or WebChannel (not REST). - * - * @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 {@link protos.google.firestore.v1.WriteRequest|WriteRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1.WriteResponse|WriteResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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. This method is only available via gRPC or WebChannel - * (not REST). - * - * @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 {@link protos.google.firestore.v1.ListenRequest|ListenRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1.ListenResponse|ListenResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {}, - 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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @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 {@link google.cloud.location.Location | Location}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. 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.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - - - /** - * 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(); - this.locationsClient.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 75487fc9b..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client_config.json +++ /dev/null @@ -1,121 +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" - }, - "RunAggregationQuery": { - "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 5c2cd76e2..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/firestore/v1/aggregation_result.proto", - "../../protos/google/firestore/v1/bloom_filter.proto", - "../../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 4fce00187..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,170 +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" - ] - }, - "RunAggregationQuery": { - "methods": [ - "runAggregationQuery" - ] - }, - "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 aac58c1b4..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 75ce02186..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 7d85b1cb7..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 598cb8f24..000000000 --- a/owl-bot-staging/v1/test/gapic_firestore_v1.ts +++ /dev/null @@ -1,2423 +0,0 @@ -// Copyright 2023 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.BeginTransactionResponse() - ); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.BatchWriteResponse() - ); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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('runAggregationQuery', () => { - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.RunAggregationQueryResponse() - ); - client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(expectedResponse); - const stream = client.runAggregationQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(undefined, expectedError); - const stream = client.runAggregationQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runAggregationQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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 d4f03a0df..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 830c28c2c..000000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index 4b3c3caa6..000000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.3" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", - "c8": "^8.0.1", - "gapic-tools": "^0.1.8", - "gts": "5.0.0", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^2.0.2", - "jsdoc-region-tag": "^2.0.1", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 1a18c41bc..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto +++ /dev/null @@ -1,82 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 de192806d..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto +++ /dev/null @@ -1,149 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 047f029e4..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 = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 7d7ef11ce..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto +++ /dev/null @@ -1,300 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 124526a59..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto +++ /dev/null @@ -1,258 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 83d1138bc..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 0e33ee732..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * Labels associated with this batch write. - */ - // const labels = [1,2,3,4] - - // 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 f07a8e5f1..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 9fa52db04..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 d1b6ef3f7..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 01e5417dd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 ca4c8dcfd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 5d262fe3c..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 ae64fb980..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 9a9e2b838..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - - // 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 808ef53d7..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 7041957dd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 3fd93dada..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 dac3b53dc..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 928b5c292..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 e585b9cfb..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": 69, - "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": 102, - "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": 74, - "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": 59, - "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": 85, - "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": 59, - "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": 63, - "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": 59, - "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": 80, - "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": 97, - "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": 90, - "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": 70, - "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": 67, - "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": 65, - "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": 76, - "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 1ef09ee45..000000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 bb138fc95..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts +++ /dev/null @@ -1,1849 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform, 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/main/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 | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'), - write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), - listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest') - }; - - // 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 = this._gaxModule.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 this._gaxModule.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._opts.fallback - ); - - 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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.BeginTransactionResponse|BeginTransactionResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.CommitResponse|CommitResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link protos.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 {@link protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {@link protos.google.firestore.v1beta1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.RunQueryResponse|RunQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.WriteRequest|WriteRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1beta1.WriteResponse|WriteResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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 {@link protos.google.firestore.v1beta1.ListenRequest|ListenRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1beta1.ListenResponse|ListenResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {}, - 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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 aac58c1b4..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 3dd1ef017..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 08f759d2b..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 b7fa1695c..000000000 --- a/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts +++ /dev/null @@ -1,2160 +0,0 @@ -// Copyright 2023 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'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.BeginTransactionResponse() - ); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.BatchWriteResponse() - ); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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', -}; From 1b15957b75abbc64a95799818b221cd15076a17f Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 24 Aug 2023 19:52:32 +0000 Subject: [PATCH 3/5] fix: simplify logic for HTTP/1.1 REST fallback option For the `fallback` parameter, all values considered as `true` in Boolean context will enable HTTP/1.1 REST fallback, since the other fallback transport, proto over HTTP, is removed from `google-gax` v4. PiperOrigin-RevId: 559812260 Source-Link: https://github.com/googleapis/googleapis/commit/6a6fd29a79fe2846001d90d93e79a19fcc303b85 Source-Link: https://github.com/googleapis/googleapis-gen/commit/56c16657e7a59122b1da94771a9ef40989c282c0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 --- 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 + owl-bot-staging/admin/v1/package.json | 58 + .../google/firestore/admin/v1/database.proto | 129 + .../google/firestore/admin/v1/field.proto | 136 + .../firestore/admin/v1/firestore_admin.proto | 512 +++ .../google/firestore/admin/v1/index.proto | 174 + .../google/firestore/admin/v1/location.proto | 31 + .../google/firestore/admin/v1/operation.proto | 223 ++ .../v1/firestore_admin.create_database.js | 75 + .../v1/firestore_admin.create_index.js | 68 + .../v1/firestore_admin.delete_index.js | 62 + .../v1/firestore_admin.export_documents.js | 78 + .../v1/firestore_admin.get_database.js | 62 + .../generated/v1/firestore_admin.get_field.js | 62 + .../generated/v1/firestore_admin.get_index.js | 62 + .../v1/firestore_admin.import_documents.js | 76 + .../v1/firestore_admin.list_databases.js | 62 + .../v1/firestore_admin.list_fields.js | 83 + .../v1/firestore_admin.list_indexes.js | 78 + .../v1/firestore_admin.update_database.js | 66 + .../v1/firestore_admin.update_field.js | 67 + ...et_metadata_google.firestore.admin.v1.json | 595 ++++ owl-bot-staging/admin/v1/src/index.ts | 25 + .../admin/v1/src/v1/firestore_admin_client.ts | 2282 +++++++++++++ .../src/v1/firestore_admin_client_config.json | 92 + .../v1/src/v1/firestore_admin_proto_list.json | 8 + .../admin/v1/src/v1/gapic_metadata.json | 161 + 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 | 2821 +++++++++++++++++ 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/package.json | 58 + .../firestore/v1/aggregation_result.proto | 43 + .../google/firestore/v1/bloom_filter.proto | 73 + .../protos/google/firestore/v1/common.proto | 90 + .../protos/google/firestore/v1/document.proto | 149 + .../google/firestore/v1/firestore.proto | 1094 +++++++ .../v1/protos/google/firestore/v1/query.proto | 506 +++ .../v1/protos/google/firestore/v1/write.proto | 286 ++ .../v1/firestore.batch_get_documents.js | 95 + .../generated/v1/firestore.batch_write.js | 73 + .../v1/firestore.begin_transaction.js | 67 + .../samples/generated/v1/firestore.commit.js | 71 + .../generated/v1/firestore.create_document.js | 85 + .../generated/v1/firestore.delete_document.js | 67 + .../generated/v1/firestore.get_document.js | 79 + .../v1/firestore.list_collection_ids.js | 82 + .../generated/v1/firestore.list_documents.js | 122 + .../samples/generated/v1/firestore.listen.js | 78 + .../generated/v1/firestore.partition_query.js | 112 + .../generated/v1/firestore.rollback.js | 67 + .../v1/firestore.run_aggregation_query.js | 90 + .../generated/v1/firestore.run_query.js | 91 + .../generated/v1/firestore.update_document.js | 82 + .../samples/generated/v1/firestore.write.js | 98 + .../snippet_metadata_google.firestore.v1.json | 867 +++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/firestore_client.ts | 2118 +++++++++++++ .../v1/src/v1/firestore_client_config.json | 121 + .../v1/src/v1/firestore_proto_list.json | 9 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 + 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 | 2423 ++++++++++++++ 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 + owl-bot-staging/v1beta1/package.json | 58 + .../google/firestore/v1beta1/common.proto | 82 + .../google/firestore/v1beta1/document.proto | 149 + .../google/firestore/v1beta1/firestore.proto | 900 ++++++ .../google/firestore/v1beta1/query.proto | 300 ++ .../google/firestore/v1beta1/write.proto | 258 ++ .../v1beta1/firestore.batch_get_documents.js | 93 + .../v1beta1/firestore.batch_write.js | 73 + .../v1beta1/firestore.begin_transaction.js | 67 + .../generated/v1beta1/firestore.commit.js | 71 + .../v1beta1/firestore.create_document.js | 84 + .../v1beta1/firestore.delete_document.js | 67 + .../v1beta1/firestore.get_document.js | 77 + .../v1beta1/firestore.list_collection_ids.js | 75 + .../v1beta1/firestore.list_documents.js | 110 + .../generated/v1beta1/firestore.listen.js | 78 + .../v1beta1/firestore.partition_query.js | 105 + .../generated/v1beta1/firestore.rollback.js | 67 + .../generated/v1beta1/firestore.run_query.js | 88 + .../v1beta1/firestore.update_document.js | 82 + .../generated/v1beta1/firestore.write.js | 98 + ...pet_metadata_google.firestore.v1beta1.json | 803 +++++ owl-bot-staging/v1beta1/src/index.ts | 25 + .../v1beta1/src/v1beta1/firestore_client.ts | 1848 +++++++++++ .../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 | 2160 +++++++++++++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + 125 files changed, 26663 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/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_database.js 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/package.json create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto create mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto 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_aggregation_query.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/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..d4f03a0df --- /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..4eaf8d13d --- /dev/null +++ b/owl-bot-staging/admin/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/admin/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/admin/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/admin/v1/package.json new file mode 100644 index 000000000..7bbc5e6d0 --- /dev/null +++ b/owl-bot-staging/admin/v1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..5d9b762a1 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto @@ -0,0 +1,129 @@ +// 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.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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. + // + // Mode changes are only allowed if the database is empty. + enum DatabaseType { + // The default value. This value is used if the database type is omitted. + DATABASE_TYPE_UNSPECIFIED = 0; + + // 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 mode is available + // for Cloud Firestore databases. + OPTIMISTIC = 1; + + // Use pessimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. + // + // This is the default setting for Cloud Firestore. + PESSIMISTIC = 2; + + // Use optimistic concurrency control with entity groups by default. + // + // This is the only available mode for Cloud Datastore. + // + // This mode is also available for Cloud Firestore with Datastore Mode but + // is not recommended. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // The type of App Engine integration mode. + enum AppEngineIntegrationMode { + // Not used. + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + + // If an App Engine application exists in the same region as this database, + // App Engine configuration will impact this database. This includes + // disabling of the application & database, as well as disabling writes to + // the database. + ENABLED = 1; + + // Appengine has no affect on the ability of this database to serve + // requests. + DISABLED = 2; + } + + // The resource name of the Database. + // Format: `projects/{project}/databases/{database}` + string name = 1; + + // 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; + + // The App Engine integration mode to use for this database. + AppEngineIntegrationMode app_engine_integration_mode = 19; + + // Output only. The key_prefix for this database. This key_prefix is used, in combination + // with the project id ("~") to construct the + // application id that is returned from the Cloud Datastore APIs in Google App + // Engine first generation runtimes. + // + // This value may be empty in which case the appid to use for URL-encoded keys + // is the project_id (eg: foo instead of v~foo). + string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // This checksum is computed by the server based on the value of other + // fields, and may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + 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..5cd1cd481 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto @@ -0,0 +1,136 @@ +// 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.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/firestore/admin/v1/index.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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; + } + + // The TTL (time-to-live) configuration for documents that have this `Field` + // set. + // Storing a timestamp value into a TTL-enabled field will be treated as + // the document's absolute expiration time. Using any other data type or + // leaving the field absent will disable the TTL for the individual document. + message TtlConfig { + // The state of applying the TTL configuration to all documents. + enum State { + // The state is unspecified or unknown. + STATE_UNSPECIFIED = 0; + + // The TTL is being applied. There is an active long-running operation to + // track the change. Newly written documents will have TTLs applied as + // requested. Requested TTLs on existing documents are still being + // processed. When TTLs on all existing documents have been processed, the + // state will move to 'ACTIVE'. + CREATING = 1; + + // The TTL is active for all documents. + ACTIVE = 2; + + // The TTL configuration could not be enabled for all existing documents. + // Newly written documents will continue to have their TTL applied. + // The LRO returned when last attempting to enable TTL for this `Field` + // has failed, and may have more details. + NEEDS_REPAIR = 3; + } + + // Output only. The state of the TTL configuration. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Required. A field name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` + // + // 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; + + // The TTL configuration for this `Field`. + // Setting or unsetting this will enable or disable the TTL for + // documents that have this `Field`. + TtlConfig ttl_config = 3; +} diff --git a/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..e1faa4dcf --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto @@ -0,0 +1,512 @@ +// Copyright 2023 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/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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" + }; + } + + // Create a database. + rpc CreateDatabase(CreateDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases" + body: "database" + }; + option (google.api.method_signature) = "parent,database,database_id"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "CreateDatabaseMetadata" + }; + } + + // 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 request for +// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]. +message CreateDatabaseRequest { + // 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" + } + ]; + + // Required. The Database to create. + Database database = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. + // + // The value must be set to "(default)". + string database_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata related to the create database operation. +message CreateDatabaseMetadata {} + +// 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..2567da650 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto @@ -0,0 +1,174 @@ +// Copyright 2023 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"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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}" + }; + + // 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; + + // Include all the collections's ancestor in the index. Only available for + // Datastore Mode databases. + COLLECTION_RECURSIVE = 3; + } + + // API Scope defines the APIs (Firestore Native, or Firestore in + // Datastore Mode) that are supported for queries. + enum ApiScope { + // The index can only be used by the Firestore Native query API. + // This is the default. + ANY_API = 0; + + // The index can only be used by the Firestore in Datastore Mode query API. + DATASTORE_MODE_API = 1; + } + + // 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; + } + } + + // 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 API scope supported by this index. + ApiScope api_scope = 5; + + // The fields supported by this index. + // + // For composite indexes, this requires a minimum of 2 and a maximum of 100 + // 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..abf836d92 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto @@ -0,0 +1,31 @@ +// 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.admin.v1; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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..6b0562293 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto @@ -0,0 +1,223 @@ +// 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.admin.v1; + +import "google/firestore/admin/v1/index.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +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; + } + + // Information about an TTL configuration change. + message TtlConfigDelta { + // Specifies how the TTL config is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The TTL config is being added. + ADD = 1; + + // The TTL config is being removed. + REMOVE = 2; + } + + // Specifies how the TTL configuration is changing. + ChangeType change_type = 1; + } + + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // 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; + + // Describes the deltas of TTL configuration. + TtlConfigDelta ttl_config_delta = 8; +} + +// 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_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js new file mode 100644 index 000000000..74fe712ca --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js @@ -0,0 +1,75 @@ +// Copyright 2023 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, database, databaseId) { + // [START firestore_v1_generated_FirestoreAdmin_CreateDatabase_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A parent name of the form + * `projects/{project_id}` + */ + // const parent = 'abc123' + /** + * Required. The Database to create. + */ + // const database = {} + /** + * Required. The ID to use for the database, which will become the final + * component of the database's resource name. + * The value must be set to "(default)". + */ + // const databaseId = 'abc123' + + // Imports the Admin library + const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; + + // Instantiates a client + const adminClient = new FirestoreAdminClient(); + + async function callCreateDatabase() { + // Construct request + const request = { + parent, + database, + databaseId, + }; + + // Run request + const [operation] = await adminClient.createDatabase(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateDatabase(); + // [END firestore_v1_generated_FirestoreAdmin_CreateDatabase_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.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js new file mode 100644 index 000000000..0cf3b60d8 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js @@ -0,0 +1,68 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..d4af852b5 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..a678fbe55 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..14fede7e8 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..f7de563b7 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..749a20bbf --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..5101ecbdc --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js @@ -0,0 +1,76 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..084fc96ef --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js @@ -0,0 +1,62 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..87d562fbe --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js @@ -0,0 +1,83 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..7c1e33448 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..cedf7f52a --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js @@ -0,0 +1,66 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..3d1e1b72f --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..96be9887a --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata_google.firestore.admin.v1.json @@ -0,0 +1,595 @@ +{ + "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": 60, + "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": 70, + "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": 54, + "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": 54, + "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": 54, + "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": 59, + "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": 75, + "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": 70, + "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": 68, + "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_CreateDatabase_async", + "title": "FirestoreAdmin createDatabase Sample", + "origin": "API_DEFINITION", + "description": " Create a database.", + "canonical": true, + "file": "firestore_admin.create_database.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "database", + "type": ".google.firestore.admin.v1.Database" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FirestoreAdminClient", + "fullName": "google.firestore.admin.v1.FirestoreAdminClient" + }, + "method": { + "shortName": "CreateDatabase", + "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", + "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": 54, + "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": 54, + "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": 58, + "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..53e4b4753 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..2a34954cf --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts @@ -0,0 +1,2282 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +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'; +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}; + locationsClient: LocationsClient; + 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/main/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/1.1 REST mode. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreAdminClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // 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 { + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback) { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/databases/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/databases/*}/operations',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 createDatabaseResponse = protoFilesRoot.lookup( + '.google.firestore.admin.v1.Database') as gax.protobuf.Type; + const createDatabaseMetadata = protoFilesRoot.lookup( + '.google.firestore.admin.v1.CreateDatabaseMetadata') 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)), + createDatabase: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createDatabaseResponse.decode.bind(createDatabaseResponse), + createDatabaseMetadata.decode.bind(createDatabaseMetadata)), + 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 = this._gaxModule.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', 'createDatabase', '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._opts.fallback + ); + + 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 {@link protos.google.firestore.admin.v1.Index|Index}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Field|Field}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Database|Database}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.ListDatabasesResponse|ListDatabasesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDatabases(request, options, callback); + } + +/** + * Creates a composite index. This returns a + * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a field configuration. Currently, field updates apply only to + * single field index configuration. However, calls to + * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateField, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportDocuments, this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Create a database. + * + * @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 {google.firestore.admin.v1.Database} request.database + * Required. The Database to create. + * @param {string} request.databaseId + * Required. The ID to use for the database, which will become the final + * component of the database's resource name. + * + * The value must be set to "(default)". + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async + */ + createDatabase( + request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createDatabase( + request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createDatabase( + request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDatabase(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createDatabase()`. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore_admin.create_database.js + * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async + */ + async checkCreateDatabaseProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createDatabase, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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' + ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatabase, this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists the field configuration and metadata for this database. + * + * Currently, + * {@link protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} + * only supports listing fields that have been explicitly overridden. To issue + * this query, call + * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. 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.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- 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.locationsClient.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..ee5860dbc --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json @@ -0,0 +1,92 @@ +{ + "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" + }, + "CreateDatabase": { + "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..c2af7c470 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json @@ -0,0 +1,161 @@ +{ + "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" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "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" + ] + }, + "CreateDatabase": { + "methods": [ + "createDatabase" + ] + }, + "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..37fe8fb3f --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..4bafec29c --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..ddf2067ee --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..03b1d8fc7 --- /dev/null +++ b/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts @@ -0,0 +1,2821 @@ +// Copyright 2023 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); + const [response] = await client.deleteIndex(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getField(request), expectedError); + const actualRequest = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDatabases(request), expectedError); + const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createIndex(request), expectedError); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createIndex(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateField(request), expectedError); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); + request.field.name = defaultValue1; + const expectedHeaderRequestParams = `field.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateField(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('createDatabase', () => { + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); + const [operation] = await client.createDatabase(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDatabase( + 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); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDatabase 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.CreateDatabaseRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(''), 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateDatabase(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); + request.database.name = defaultValue1; + const expectedHeaderRequestParams = `database.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateDatabase(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listIndexes(request), expectedError); + const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFields(request), expectedError); + const actualRequest = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listFields.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new firestoreadminModule.v1.FirestoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + 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..d4f03a0df --- /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..16a892325 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..4d1a26fc7 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto new file mode 100644 index 000000000..05fea5da9 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto @@ -0,0 +1,43 @@ +// Copyright 2023 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/document.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "AggregationResultProto"; +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"; + +// The result of a single bucket from a Firestore aggregation query. +// +// The keys of `aggregate_fields` are the same for all results in an aggregation +// query, unlike document queries which can have different fields present for +// each result. +message AggregationResult { + // The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. + // + // The key is the + // [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias] + // assigned to the aggregation function on input and the size of this map + // equals the number of aggregation functions in the query. + map aggregate_fields = 2; +} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto new file mode 100644 index 000000000..c00bb9c17 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto @@ -0,0 +1,73 @@ +// Copyright 2023 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; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "BloomFilterProto"; +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 sequence of bits, encoded in a byte array. +// +// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only +// exception is the last byte, which may store 8 _or fewer_ bits. The `padding` +// defines the number of bits of the last byte to be ignored as "padding". The +// values of these "padding" bits are unspecified and must be ignored. +// +// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. +// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. +// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. +// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. +// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. +// +// The "size" of a `BitSequence` (the number of bits it contains) is calculated +// by this formula: `(bitmap.length * 8) - padding`. +message BitSequence { + // The bytes that encode the bit sequence. + // May have a length of zero. + bytes bitmap = 1; + + // The number of bits of the last byte in `bitmap` to ignore as "padding". + // If the length of `bitmap` is zero, then this value must be `0`. + // Otherwise, this value must be between 0 and 7, inclusive. + int32 padding = 2; +} + +// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). +// +// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit +// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers +// using 2's complement encoding. +// +// These two hash values, named `h1` and `h2`, are then used to compute the +// `hash_count` hash values using the formula, starting at `i=0`: +// +// h(i) = h1 + (i * h2) +// +// These resulting values are then taken modulo the number of bits in the bloom +// filter to get the bits of the bloom filter to test for the given entry. +message BloomFilter { + // The bloom filter data. + BitSequence bits = 1; + + // The number of hashes used by the algorithm. + int32 hash_count = 2; +} 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..2a562aa6e --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/common.proto @@ -0,0 +1,90 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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. + // + // Firestore does not allow 3rd party auth requests to create read-write. + // transactions. + 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 must be a microsecond precision timestamp within the past one + // hour, or if Point-in-Time Recovery is enabled, can additionally be a + // whole minute timestamp within the past 7 days. + 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..795200498 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/document.proto @@ -0,0 +1,149 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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..a4447d167 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto @@ -0,0 +1,1094 @@ +// Copyright 2023 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/aggregation_result.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/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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 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: "*" + } + }; + } + + // Runs an aggregation query. + // + // Rather than producing [Document][google.firestore.v1.Document] results like + // [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API + // allows running an aggregation to produce a series of + // [AggregationResult][google.firestore.v1.AggregationResult] server-side. + // + // High-Level Example: + // + // ``` + // -- Return the number of documents in table given a filter. + // SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + // ``` + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (stream RunAggregationQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery" + 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. This method is + // only available via gRPC or WebChannel (not REST). + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. This method is only available via gRPC or WebChannel + // (not REST). + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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]; + + // Optional. The collection ID, relative to `parent`, to list. + // + // For example: `chatrooms` or `messages`. + // + // This is optional, and when not provided, Firestore will list documents + // from all collections under the provided `parent`. + string collection_id = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of documents to return in a single response. + // + // Firestore may return fewer than this value. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListDocuments` response. + // + // Provide this to retrieve the subsequent page. When paginating, all other + // parameters (with the exception of `page_size`) must match the values set + // in the request that generated the page token. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The optional ordering of the documents to return. + // + // For example: `priority desc, __name__ desc`. + // + // This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by] + // used in Firestore queries but in a string representation. When absent, + // documents are ordered based on `__name__ ASC`. + string order_by = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. 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 [(google.api.field_behavior) = OPTIONAL]; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Perform the read as part of an already active transaction. + bytes transaction = 8; + + // Perform the read at the provided time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 10; + } + + // If the list should show missing documents. + // + // A document is missing if it does not exist, but there are sub-documents + // nested underneath it. When true, such missing documents will be returned + // with a key but will not have fields, + // [`create_time`][google.firestore.v1.Document.create_time], or + // [`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; + + // A token to retrieve the next page of documents. + // + // If this field is omitted, there are no subsequent pages. + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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 must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + 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.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryRequest { + // 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 { + // An aggregation query. + StructuredAggregationQuery structured_aggregation_query = 2; + } + + // The consistency mode for the query, defaults to strong consistency. + oneof consistency_selector { + // Run the aggregation within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 4; + + // Starts a new transaction as part of the query, defaulting to read-only. + // + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Executes the query at the given timestamp. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } +} + +// The response for +// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryResponse { + // A single aggregation result. + // + // Not present when reporting partial progress. + AggregationResult result = 1; + + // The transaction that was started as part of this request. + // + // Only present on the first response when the request requested to start + // a new transaction. + bytes transaction = 2; + + // The time at which the aggregate result was computed. This is always + // monotonically increasing; in this case, the previous AggregationResult 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 + // `result` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; +} + +// 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 consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } +} + +// 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 specified, only the matching Documents that have been updated AFTER the + // `resume_token` or `read_time` will be returned. Otherwise, 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; + + // The number of documents that last matched the query at the resume token or + // read time. + // + // This value is only relevant when a `resume_type` is provided. This value + // being present and greater than zero signals that the client wants + // `ExistenceFilter.unchanged_names` to be included in the response. + google.protobuf.Int32Value expected_count = 12; +} + +// 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 consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 4; + } +} + +// 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..4a4919634 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/query.proto @@ -0,0 +1,506 @@ +// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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; + + // Documents are required to satisfy at least one of the combined filters. + OR = 2; + } + + // 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`, subject to disjunction + // limits. + // * No `NOT_IN` filters in the same query. + 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`, subject to disjunction + // limits. + // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction. + // * No `NOT_IN` filters in the same query. + 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 `OR`, `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 in a document, ex: `stats.operations`. + message FieldReference { + // The relative path of the document being referenced. + // + // Requires: + // + // * Conform to [document field name][google.firestore.v1.Document.fields] + // limitations. + 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; + } + + // Optional sub-set of the fields to return. + // + // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the + // documents returned from a query. When not set, assumes that the caller + // wants all fields returned. + 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 allows callers to provide a full ordering, a partial ordering, or + // no ordering at all. In all cases, Firestore guarantees a stable ordering + // through the following rules: + // + // * The `order_by` is required to reference all fields used with an + // inequality filter. + // * All fields that are required to be in the `order_by` but are not already + // present are appended in lexicographical ordering of the field name. + // * 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: + // + // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` + // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` + // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` + // * `WHERE __name__ > ... AND a > 1` becomes + // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC` + repeated Order order_by = 4; + + // A potential prefix of a position in the result set to start the query at. + // + // The ordering of the result set is based on the `ORDER BY` clause of the + // original query. + // + // ``` + // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; + // ``` + // + // This query's results are ordered by `(b ASC, __name__ ASC)`. + // + // Cursors can reference either the full ordering or a prefix of the location, + // though it cannot reference more fields than what are in the provided + // `ORDER BY`. + // + // Continuing off the example above, attaching the following start cursors + // will have varying impact: + // + // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND + // b > 2 AND __name__ > /k/123`. + // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. + // + // Unlike `OFFSET` which requires scanning over the first N results to skip, + // a start cursor allows the query to begin at a logical position. This + // position is not required to match an actual result, it will scan forward + // from this position to find the next document. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor start_at = 7; + + // A potential prefix of a position in the result set to end the query at. + // + // This is similar to `START_AT` but with it controlling the end position + // rather than the start position. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor end_at = 8; + + // The number of documents to skip before returning the first result. + // + // This applies after the constraints specified by the `WHERE`, `START AT`, & + // `END AT` but before the `LIMIT` clause. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + google.protobuf.Int32Value limit = 5; +} + +// Firestore query for running an aggregation over a +// [StructuredQuery][google.firestore.v1.StructuredQuery]. +message StructuredAggregationQuery { + // Defines an aggregation that produces a single result. + message Aggregation { + // Count of documents that match the query. + // + // The `COUNT(*)` aggregation function operates on the entire document + // so it does not require a field reference. + message Count { + // Optional. Optional constraint on the maximum number of documents to + // count. + // + // This provides a way to set an upper bound on the number of documents + // to scan, limiting latency, and cost. + // + // Unspecified is interpreted as no bound. + // + // High-Level Example: + // + // ``` + // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); + // ``` + // + // Requires: + // + // * Must be greater than zero when present. + google.protobuf.Int64Value up_to = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Sum of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns 0. + // + // * Returns a 64-bit integer if all aggregated numbers are integers and the + // sum result does not overflow. Otherwise, the result is returned as a + // double. Note that even if all the aggregated values are integers, the + // result is returned as a double if it cannot fit within a 64-bit signed + // integer. When this occurs, the returned value will lose precision. + // + // * When underflow occurs, floating-point aggregation is non-deterministic. + // This means that running the same query repeatedly without any changes to + // the underlying values could produce slightly different results each + // time. In those cases, values should be stored as integers over + // floating-point numbers. + message Sum { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // Average of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns `NULL`. + // + // * Always returns the result as a double. + message Avg { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // The type of aggregation to perform, required. + oneof operator { + // Count aggregator. + Count count = 1; + + // Sum aggregator. + Sum sum = 2; + + // Average aggregator. + Avg avg = 3; + } + + // Optional. Optional name of the field to store the result of the + // aggregation into. + // + // If not provided, Firestore will pick a default name following the format + // `field_`. For example: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2), + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) + // OVER ( + // ... + // ); + // ``` + // + // becomes: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2) AS field_1, + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) AS field_2 + // OVER ( + // ... + // ); + // ``` + // + // Requires: + // + // * Must be unique across all aggregation aliases. + // * Conform to [document field name][google.firestore.v1.Document.fields] + // limitations. + string alias = 7 [(google.api.field_behavior) = OPTIONAL]; + } + + // The base query to aggregate over. + oneof query_type { + // Nested structured query. + StructuredQuery structured_query = 1; + } + + // Optional. Series of aggregations to apply over the results of the + // `structured_query`. + // + // Requires: + // + // * A minimum of one and maximum of five aggregations per query. + repeated Aggregation aggregations = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// 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..4b46595ce --- /dev/null +++ b/owl-bot-staging/v1/protos/google/firestore/v1/write.proto @@ -0,0 +1,286 @@ +// Copyright 2023 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/bloom_filter.proto"; +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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +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. + // + // The client can use the `unchanged_names` bloom filter to assist with + // this determination by testing ALL the document names against the filter; + // if the document name is NOT in the filter, it means the document no + // longer matches the target. + int32 count = 2; + + // A bloom filter that, despite its name, contains the UTF-8 byte encodings of + // the resource names of ALL the documents that match + // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // + // This bloom filter may be omitted at the server's discretion, such as if it + // is deemed that the client will not make use of it or if it is too + // computationally expensive to calculate or transmit. Clients must gracefully + // handle this field being absent by falling back to the logic used before + // this field existed; that is, re-add the target without a resume token to + // figure out which documents in the client's cache are out of sync. + BloomFilter unchanged_names = 3; +} 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..d1be99f6f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js @@ -0,0 +1,95 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..2180becfe --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js @@ -0,0 +1,73 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * Labels associated with this batch write. + */ + // const labels = [1,2,3,4] + + // 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..fe03086ab --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..70f3ba056 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js @@ -0,0 +1,71 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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..0d1894891 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js @@ -0,0 +1,85 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..bbb97ac7d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..93ad08cc9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js @@ -0,0 +1,79 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..463d68372 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Reads documents as they were at the given time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // 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..a271d2fa3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js @@ -0,0 +1,122 @@ +// Copyright 2023 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_ListDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Optional. The collection ID, relative to `parent`, to list. + * For example: `chatrooms` or `messages`. + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + */ + // const collectionId = 'abc123' + /** + * Optional. The maximum number of documents to return in a single response. + * Firestore may return fewer than this value. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListDocuments` response. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + */ + // const pageToken = 'abc123' + /** + * Optional. The optional ordering of the documents to return. + * For example: `priority desc, __name__ desc`. + * This mirrors the `ORDER BY` google.firestore.v1.StructuredQuery.order_by + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + */ + // const orderBy = 'abc123' + /** + * Optional. 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 = {} + /** + * Perform the read as part of an already active transaction. + */ + // const transaction = Buffer.from('string') + /** + * Perform the read at the provided time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + /** + * If the list should show missing documents. + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * `create_time` google.firestore.v1.Document.create_time, or + * `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, + }; + + // 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..8b38795d5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + + // 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..84acded1b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js @@ -0,0 +1,112 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 + /** + * Reads documents as they were at the given time. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // 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..0c75482d1 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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_aggregation_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js new file mode 100644 index 000000000..4e3d4f025 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js @@ -0,0 +1,90 @@ +// Copyright 2023 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_RunAggregationQuery_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * An aggregation query. + */ + // const structuredAggregationQuery = {} + /** + * Run the aggregation 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 as part of the query, defaulting to read-only. + * The new transaction ID will be returned as the first response in the + * stream. + */ + // const newTransaction = {} + /** + * Executes the query at the given timestamp. + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // const readTime = {} + + // Imports the Firestore library + const {FirestoreClient} = require('@google-cloud/firestore').v1; + + // Instantiates a client + const firestoreClient = new FirestoreClient(); + + async function callRunAggregationQuery() { + // Construct request + const request = { + parent, + }; + + // Run request + const stream = await firestoreClient.runAggregationQuery(request); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + } + + callRunAggregationQuery(); + // [END firestore_v1_generated_Firestore_RunAggregationQuery_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..2717ffa3b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js @@ -0,0 +1,91 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + */ + // 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..904a7cd3a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..8cfd43d15 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/firestore.write.js @@ -0,0 +1,98 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..321061a5c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata_google.firestore.v1.json @@ -0,0 +1,867 @@ +{ + "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": 71, + "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": 114, + "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": 74, + "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": 59, + "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": 87, + "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": 59, + "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": 63, + "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": 59, + "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": 83, + "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_RunAggregationQuery_async", + "title": "Firestore runAggregationQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs an aggregation query. Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```", + "canonical": true, + "file": "firestore.run_aggregation_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunAggregationQuery", + "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "structured_aggregation_query", + "type": ".google.firestore.v1.StructuredAggregationQuery" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "new_transaction", + "type": ".google.firestore.v1.TransactionOptions" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "resultType": ".google.firestore.v1.RunAggregationQueryResponse", + "client": { + "shortName": "FirestoreClient", + "fullName": "google.firestore.v1.FirestoreClient" + }, + "method": { + "shortName": "RunAggregationQuery", + "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", + "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": 104, + "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" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "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. This method is only available via gRPC or WebChannel (not REST).", + "canonical": true, + "file": "firestore.write.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "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. This method is only available via gRPC or WebChannel (not REST).", + "canonical": true, + "file": "firestore.listen.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "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": 74, + "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" + }, + { + "name": "read_time", + "type": ".google.protobuf.Timestamp" + } + ], + "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": 65, + "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": 77, + "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..30d0870ac --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..93b2a5294 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client.ts @@ -0,0 +1,2118 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform, 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 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}; + locationsClient: LocationsClient; + 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/main/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/1.1 REST mode. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // 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 { + 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(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), + runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), + runAggregationQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), + write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback), + listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback) + }; + + // 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 = this._gaxModule.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', 'runAggregationQuery', '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 this._gaxModule.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._opts.fallback + ); + + 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.BeginTransactionResponse|BeginTransactionResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.CommitResponse|CommitResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the + * success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link protos.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 {@link protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.RunQueryResponse|RunQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.runQuery(request, options); + } + +/** + * Runs an aggregation query. + * + * Rather than producing {@link protos.google.firestore.v1.Document|Document} results like + * {@link protos.google.firestore.v1.Firestore.RunQuery|Firestore.RunQuery}, this API + * allows running an aggregation to produce a series of + * {@link protos.google.firestore.v1.AggregationResult|AggregationResult} server-side. + * + * High-Level Example: + * + * ``` + * -- Return the number of documents in table given a filter. + * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + * ``` + * + * @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.StructuredAggregationQuery} request.structuredAggregationQuery + * An aggregation query. + * @param {Buffer} request.transaction + * Run the aggregation 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 as part of the query, defaulting to read-only. + * + * The new transaction ID will be returned as the first response in the + * stream. + * @param {google.protobuf.Timestamp} request.readTime + * Executes the query at the given timestamp. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * for more details and examples. + * @example include:samples/generated/v1/firestore.run_aggregation_query.js + * region_tag:firestore_v1_generated_Firestore_RunAggregationQuery_async + */ + runAggregationQuery( + request?: protos.google.firestore.v1.IRunAggregationQueryRequest, + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.runAggregationQuery(request, options); + } + +/** + * Streams batches of document updates and deletes, in order. This method is + * only available via gRPC or WebChannel (not REST). + * + * @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 {@link protos.google.firestore.v1.WriteRequest|WriteRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1.WriteResponse|WriteResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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. This method is only available via gRPC or WebChannel + * (not REST). + * + * @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 {@link protos.google.firestore.v1.ListenRequest|ListenRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1.ListenResponse|ListenResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as 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] + * Optional. The collection ID, relative to `parent`, to list. + * + * For example: `chatrooms` or `messages`. + * + * This is optional, and when not provided, Firestore will list documents + * from all collections under the provided `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of documents to return in a single response. + * + * Firestore may return fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListDocuments` response. + * + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters (with the exception of `page_size`) must match the values set + * in the request that generated the page token. + * @param {string} [request.orderBy] + * Optional. The optional ordering of the documents to return. + * + * For example: `priority desc, __name__ desc`. + * + * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} + * used in Firestore queries but in a string representation. When absent, + * documents are ordered based on `__name__ ASC`. + * @param {google.firestore.v1.DocumentMask} [request.mask] + * Optional. 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 + * Perform the read as part of an already active transaction. + * @param {google.protobuf.Timestamp} request.readTime + * Perform the read at the provided time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @param {boolean} request.showMissing + * If the list should show missing documents. + * + * A document is missing if it does not exist, but there are sub-documents + * nested underneath it. When true, such missing documents will be returned + * with a key but will not have fields, + * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or + * {@link protos.google.firestore.v1.Document.update_time|`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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {}, + 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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. + * @param {google.protobuf.Timestamp} request.readTime + * Reads documents as they were at the given time. + * + * This must be a microsecond precision timestamp within the past one hour, + * or if Point-in-Time Recovery is enabled, can additionally be a whole + * minute timestamp within the past 7 days. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @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 {@link google.cloud.location.Location | Location}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. 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.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + + /** + * 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(); + this.locationsClient.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..75487fc9b --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_client_config.json @@ -0,0 +1,121 @@ +{ + "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" + }, + "RunAggregationQuery": { + "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..5c2cd76e2 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/firestore_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/firestore/v1/aggregation_result.proto", + "../../protos/google/firestore/v1/bloom_filter.proto", + "../../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..4fce00187 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,170 @@ +{ + "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" + ] + }, + "RunAggregationQuery": { + "methods": [ + "runAggregationQuery" + ] + }, + "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..aac58c1b4 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..75ce02186 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..7d85b1cb7 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..598cb8f24 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_firestore_v1.ts @@ -0,0 +1,2423 @@ +// Copyright 2023 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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('runAggregationQuery', () => { + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1.RunAggregationQueryResponse() + ); + client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(expectedResponse); + const stream = client.runAggregationQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(undefined, expectedError); + const stream = client.runAggregationQuery(request); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + resolve(response); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runAggregationQuery 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.RunAggregationQueryRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runAggregationQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + const promise = new Promise((resolve, reject) => { + stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new firestoreModule.v1.FirestoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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..d4f03a0df --- /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..830c28c2c --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 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 2023 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..1a38f257d --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 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..55639e70f --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 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/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 000000000..92b2aa0cf --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,58 @@ +{ + "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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "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": "^4.0.3" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.16", + "c8": "^8.0.1", + "gapic-tools": "^0.1.8", + "gts": "5.0.1", + "jsdoc": "^4.0.2", + "jsdoc-region-tag": "^3.0.0", + "jsdoc-fresh": "^3.0.0", + "mocha": "^10.2.0", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.2.0", + "typescript": "5.1.6" + }, + "engines": { + "node": ">=v14" + } +} 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..1a18c41bc --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto @@ -0,0 +1,82 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..de192806d --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto @@ -0,0 +1,149 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..047f029e4 --- /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 = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..7d7ef11ce --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto @@ -0,0 +1,300 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..124526a59 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto @@ -0,0 +1,258 @@ +// 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"; + +option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; +option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; +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..83d1138bc --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js @@ -0,0 +1,93 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = ['abc','def'] + /** + * 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..0e33ee732 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js @@ -0,0 +1,73 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * Labels associated with this batch write. + */ + // const labels = [1,2,3,4] + + // 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..f07a8e5f1 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..9fa52db04 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js @@ -0,0 +1,71 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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..d1b6ef3f7 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js @@ -0,0 +1,84 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..01e5417dd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..ca4c8dcfd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js @@ -0,0 +1,77 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..5d262fe3c --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js @@ -0,0 +1,75 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..ae64fb980 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js @@ -0,0 +1,110 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..9a9e2b838 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js @@ -0,0 +1,78 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + + // 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..808ef53d7 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js @@ -0,0 +1,105 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..7041957dd --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js @@ -0,0 +1,67 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..3fd93dada --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js @@ -0,0 +1,88 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..dac3b53dc --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js @@ -0,0 +1,82 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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..928b5c292 --- /dev/null +++ b/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js @@ -0,0 +1,98 @@ +// Copyright 2023 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 = [1,2,3,4] + /** + * 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 = [1,2,3,4] + + // 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..e585b9cfb --- /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": 69, + "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": 102, + "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": 74, + "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": 59, + "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": 85, + "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": 59, + "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": 63, + "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": 59, + "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": 80, + "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": 97, + "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": 90, + "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": 70, + "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": 67, + "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": 65, + "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": 76, + "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..1ef09ee45 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2023 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..0e3285761 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts @@ -0,0 +1,1848 @@ +// Copyright 2023 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 type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform, 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/main/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/1.1 REST mode. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new FirestoreClient({fallback: true}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // 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 { + 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(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), + runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), + write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback), + listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback) + }; + + // 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 = this._gaxModule.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 this._gaxModule.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._opts.fallback + ); + + 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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.BeginTransactionResponse|BeginTransactionResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.CommitResponse|CommitResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. + * + * If you require an atomically applied set of writes, use + * {@link protos.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 {@link protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {@link protos.google.firestore.v1beta1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.RunQueryResponse|RunQueryResponse} on 'data' event. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.WriteRequest|WriteRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1beta1.WriteResponse|WriteResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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 {@link protos.google.firestore.v1beta1.ListenRequest|ListenRequest} for write() method, and + * will emit objects representing {@link protos.google.firestore.v1beta1.ListenResponse|ListenResponse} on 'data' event asynchronously. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } + * 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + const defaultCallSettings = this._defaults['listDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocuments.createStream( + this.innerApiCalls.listDocuments as 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, + * or {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + 'collection_id': request.collectionId ?? '', + }); + 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 {}, + 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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * 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' + ] = this._gaxModule.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 {}, + 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..aac58c1b4 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2023 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..3dd1ef017 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2023 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..08f759d2b --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2023 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..c8f81b25a --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 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..b7fa1695c --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts @@ -0,0 +1,2160 @@ +// Copyright 2023 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'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + const expectedHeaderRequestParams = `document.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); + request.document.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BeginTransactionResponse() + ); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.CommitResponse() + ); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + const actualRequest = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + const actualRequest = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.BatchWriteResponse() + ); + client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); + const [response] = await client.batchWrite(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchWrite(request), expectedError); + const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); + request.database = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedResponse = generateSampleMessage( + new protos.google.firestore.v1beta1.Document() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); + request.collectionId = defaultValue2; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedHeaderRequestParams = `database=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); + request.database = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const defaultValue2 = + getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); + request.collectionId = defaultValue2; + const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; + 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( + (client.descriptors.page.listDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.partitionQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); + const [response] = await client.listCollectionIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCollectionIds(request), expectedError); + const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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 d145c2a581762b4fe4ecb717ed191faaca33236d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 26 Sep 2023 22:52:39 +0000 Subject: [PATCH 4/5] build: update typescript generator version to publish in dual format (ESM) PiperOrigin-RevId: 568643156 Source-Link: https://github.com/googleapis/googleapis/commit/f95afc063e20a0a61e13b186806ac84b49e329cf Source-Link: https://github.com/googleapis/googleapis-gen/commit/bbd2c49d2e423a8ce5cc85627402d512aeefc58b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmJkMmM0OWQyZTQyM2E4Y2U1Y2M4NTYyNzQwMmQ1MTJhZWVmYzU4YiJ9 --- owl-bot-staging/admin/v1/package.json | 8 ++++---- owl-bot-staging/v1/package.json | 8 ++++---- owl-bot-staging/v1beta1/package.json | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/owl-bot-staging/admin/v1/package.json b/owl-bot-staging/admin/v1/package.json index 7bbc5e6d0..00c1a1a85 100644 --- a/owl-bot-staging/admin/v1/package.json +++ b/owl-bot-staging/admin/v1/package.json @@ -35,18 +35,18 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^4.0.3" + "google-gax": "^4.0.4" }, "devDependencies": { "@types/mocha": "^10.0.1", "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", + "@types/sinon": "^10.0.17", "c8": "^8.0.1", - "gapic-tools": "^0.1.8", + "gapic-tools": "^0.2.0", "gts": "5.0.1", "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", "jsdoc-fresh": "^3.0.0", + "jsdoc-region-tag": "^3.0.0", "mocha": "^10.2.0", "pack-n-play": "^1.0.0-2", "sinon": "^15.2.0", diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json index 4d1a26fc7..63195a564 100644 --- a/owl-bot-staging/v1/package.json +++ b/owl-bot-staging/v1/package.json @@ -35,18 +35,18 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^4.0.3" + "google-gax": "^4.0.4" }, "devDependencies": { "@types/mocha": "^10.0.1", "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", + "@types/sinon": "^10.0.17", "c8": "^8.0.1", - "gapic-tools": "^0.1.8", + "gapic-tools": "^0.2.0", "gts": "5.0.1", "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", "jsdoc-fresh": "^3.0.0", + "jsdoc-region-tag": "^3.0.0", "mocha": "^10.2.0", "pack-n-play": "^1.0.0-2", "sinon": "^15.2.0", diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json index 92b2aa0cf..2240d9b31 100644 --- a/owl-bot-staging/v1beta1/package.json +++ b/owl-bot-staging/v1beta1/package.json @@ -35,18 +35,18 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^4.0.3" + "google-gax": "^4.0.4" }, "devDependencies": { "@types/mocha": "^10.0.1", "@types/node": "^18.11.18", - "@types/sinon": "^10.0.16", + "@types/sinon": "^10.0.17", "c8": "^8.0.1", - "gapic-tools": "^0.1.8", + "gapic-tools": "^0.2.0", "gts": "5.0.1", "jsdoc": "^4.0.2", - "jsdoc-region-tag": "^3.0.0", "jsdoc-fresh": "^3.0.0", + "jsdoc-region-tag": "^3.0.0", "mocha": "^10.2.0", "pack-n-play": "^1.0.0-2", "sinon": "^15.2.0", From 3153c329b11a0a1eddd26f6baa8763d02d59d15d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 26 Sep 2023 22:55:29 +0000 Subject: [PATCH 5/5] =?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 --- dev/protos/google/api/field_behavior.proto | 14 + dev/protos/google/protobuf/descriptor.proto | 82 +- dev/src/v1/firestore_admin_client.ts | 9 +- dev/src/v1/firestore_client.ts | 17 +- dev/src/v1beta1/firestore_client.ts | 15 +- 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 - owl-bot-staging/admin/v1/package.json | 58 - .../google/firestore/admin/v1/database.proto | 129 - .../google/firestore/admin/v1/field.proto | 136 - .../firestore/admin/v1/firestore_admin.proto | 512 --- .../google/firestore/admin/v1/index.proto | 174 - .../google/firestore/admin/v1/location.proto | 31 - .../google/firestore/admin/v1/operation.proto | 223 -- .../v1/firestore_admin.create_database.js | 75 - .../v1/firestore_admin.create_index.js | 68 - .../v1/firestore_admin.delete_index.js | 62 - .../v1/firestore_admin.export_documents.js | 78 - .../v1/firestore_admin.get_database.js | 62 - .../generated/v1/firestore_admin.get_field.js | 62 - .../generated/v1/firestore_admin.get_index.js | 62 - .../v1/firestore_admin.import_documents.js | 76 - .../v1/firestore_admin.list_databases.js | 62 - .../v1/firestore_admin.list_fields.js | 83 - .../v1/firestore_admin.list_indexes.js | 78 - .../v1/firestore_admin.update_database.js | 66 - .../v1/firestore_admin.update_field.js | 67 - ...et_metadata_google.firestore.admin.v1.json | 595 ---- owl-bot-staging/admin/v1/src/index.ts | 25 - .../admin/v1/src/v1/firestore_admin_client.ts | 2282 ------------- .../src/v1/firestore_admin_client_config.json | 92 - .../v1/src/v1/firestore_admin_proto_list.json | 8 - .../admin/v1/src/v1/gapic_metadata.json | 161 - 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 | 2821 ----------------- 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/package.json | 58 - .../firestore/v1/aggregation_result.proto | 43 - .../google/firestore/v1/bloom_filter.proto | 73 - .../protos/google/firestore/v1/common.proto | 90 - .../protos/google/firestore/v1/document.proto | 149 - .../google/firestore/v1/firestore.proto | 1094 ------- .../v1/protos/google/firestore/v1/query.proto | 506 --- .../v1/protos/google/firestore/v1/write.proto | 286 -- .../v1/firestore.batch_get_documents.js | 95 - .../generated/v1/firestore.batch_write.js | 73 - .../v1/firestore.begin_transaction.js | 67 - .../samples/generated/v1/firestore.commit.js | 71 - .../generated/v1/firestore.create_document.js | 85 - .../generated/v1/firestore.delete_document.js | 67 - .../generated/v1/firestore.get_document.js | 79 - .../v1/firestore.list_collection_ids.js | 82 - .../generated/v1/firestore.list_documents.js | 122 - .../samples/generated/v1/firestore.listen.js | 78 - .../generated/v1/firestore.partition_query.js | 112 - .../generated/v1/firestore.rollback.js | 67 - .../v1/firestore.run_aggregation_query.js | 90 - .../generated/v1/firestore.run_query.js | 91 - .../generated/v1/firestore.update_document.js | 82 - .../samples/generated/v1/firestore.write.js | 98 - .../snippet_metadata_google.firestore.v1.json | 867 ----- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/firestore_client.ts | 2118 ------------- .../v1/src/v1/firestore_client_config.json | 121 - .../v1/src/v1/firestore_proto_list.json | 9 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 170 - 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 | 2423 -------------- 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 - owl-bot-staging/v1beta1/package.json | 58 - .../google/firestore/v1beta1/common.proto | 82 - .../google/firestore/v1beta1/document.proto | 149 - .../google/firestore/v1beta1/firestore.proto | 900 ------ .../google/firestore/v1beta1/query.proto | 300 -- .../google/firestore/v1beta1/write.proto | 258 -- .../v1beta1/firestore.batch_get_documents.js | 93 - .../v1beta1/firestore.batch_write.js | 73 - .../v1beta1/firestore.begin_transaction.js | 67 - .../generated/v1beta1/firestore.commit.js | 71 - .../v1beta1/firestore.create_document.js | 84 - .../v1beta1/firestore.delete_document.js | 67 - .../v1beta1/firestore.get_document.js | 77 - .../v1beta1/firestore.list_collection_ids.js | 75 - .../v1beta1/firestore.list_documents.js | 110 - .../generated/v1beta1/firestore.listen.js | 78 - .../v1beta1/firestore.partition_query.js | 105 - .../generated/v1beta1/firestore.rollback.js | 67 - .../generated/v1beta1/firestore.run_query.js | 88 - .../v1beta1/firestore.update_document.js | 82 - .../generated/v1beta1/firestore.write.js | 98 - ...pet_metadata_google.firestore.v1beta1.json | 803 ----- owl-bot-staging/v1beta1/src/index.ts | 25 - .../v1beta1/src/v1beta1/firestore_client.ts | 1848 ----------- .../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 | 2160 ------------- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - 130 files changed, 95 insertions(+), 26705 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/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_database.js 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/package.json delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto delete mode 100644 owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto 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_aggregation_query.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/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/api/field_behavior.proto b/dev/protos/google/api/field_behavior.proto index 1a3a2f2fb..344cb0b1f 100644 --- a/dev/protos/google/api/field_behavior.proto +++ b/dev/protos/google/api/field_behavior.proto @@ -87,4 +87,18 @@ enum FieldBehavior { // a non-empty value will be returned. The user will not be aware of what // non-empty value to expect. NON_EMPTY_DEFAULT = 7; + + // Denotes that the field in a resource (a message annotated with + // google.api.resource) is used in the resource name to uniquely identify the + // resource. For AIP-compliant APIs, this should only be applied to the + // `name` field on the resource. + // + // This behavior should not be applied to references to other resources within + // the message. + // + // The identifier field of resources often have different field behavior + // depending on the request it is embedded in (e.g. for Create methods name + // is optional and unused, while for Update methods it is required). Instead + // of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8; } diff --git a/dev/protos/google/protobuf/descriptor.proto b/dev/protos/google/protobuf/descriptor.proto index 5f148224c..fb4a3605c 100644 --- a/dev/protos/google/protobuf/descriptor.proto +++ b/dev/protos/google/protobuf/descriptor.proto @@ -57,6 +57,25 @@ message FileDescriptorSet { repeated FileDescriptorProto file = 1; } +// The full set of known editions. +enum Edition { + // A placeholder for an unknown edition value. + EDITION_UNKNOWN = 0; + + // Editions that have been released. The specific values are arbitrary and + // should not be depended on, but they will always be time-ordered for easy + // comparison. + EDITION_2023 = 1000; + + // Placeholder editions for testing feature resolution. These should not be + // used or relyed on outside of tests. + EDITION_1_TEST_ONLY = 1; + EDITION_2_TEST_ONLY = 2; + EDITION_99997_TEST_ONLY = 99997; + EDITION_99998_TEST_ONLY = 99998; + EDITION_99999_TEST_ONLY = 99999; +} + // Describes a complete .proto file. message FileDescriptorProto { optional string name = 1; // file name, relative to root of source tree @@ -90,8 +109,8 @@ message FileDescriptorProto { // If `edition` is present, this value must be "editions". optional string syntax = 12; - // The edition of the proto file, which is an opaque string. - optional string edition = 13; + // The edition of the proto file. + optional Edition edition = 14; } // Describes a message type. @@ -174,7 +193,7 @@ message ExtensionRangeOptions { } // The verification state of the range. - // TODO(b/278783756): flip the default to DECLARATION once all empty ranges + // TODO: flip the default to DECLARATION once all empty ranges // are marked as UNVERIFIED. optional VerificationState verification = 3 [default = UNVERIFIED]; @@ -574,7 +593,7 @@ message MessageOptions { // This should only be used as a temporary measure against broken builds due // to the change in behavior for JSON field name conflicts. // - // TODO(b/261750190) This is legacy behavior we plan to remove once downstream + // TODO This is legacy behavior we plan to remove once downstream // teams have had time to migrate. optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; @@ -721,7 +740,7 @@ message FieldOptions { repeated OptionTargetType targets = 19; message EditionDefault { - optional string edition = 1; + optional Edition edition = 3; optional string value = 2; // Textproto value. } repeated EditionDefault edition_defaults = 20; @@ -768,7 +787,7 @@ message EnumOptions { // and strips underscored from the fields before comparison in proto3 only. // The new behavior takes `json_name` into account and applies to proto2 as // well. - // TODO(b/261750190) Remove this legacy behavior once downstream teams have + // TODO Remove this legacy behavior once downstream teams have // had time to migrate. optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; @@ -892,7 +911,7 @@ message UninterpretedOption { // =================================================================== // Features -// TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are +// TODO Enums in C++ gencode (and potentially other languages) are // not well scoped. This means that each of the feature enums below can clash // with each other. The short names we've chosen maximize call-site // readability, but leave us very open to this scenario. A future feature will @@ -909,7 +928,7 @@ message FeatureSet { retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "EXPLICIT" } + edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" } ]; enum EnumType { @@ -921,7 +940,7 @@ message FeatureSet { retention = RETENTION_RUNTIME, targets = TARGET_TYPE_ENUM, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "OPEN" } + edition_defaults = { edition: EDITION_2023, value: "OPEN" } ]; enum RepeatedFieldEncoding { @@ -933,20 +952,19 @@ message FeatureSet { retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "PACKED" } + edition_defaults = { edition: EDITION_2023, value: "PACKED" } ]; - enum StringFieldValidation { - STRING_FIELD_VALIDATION_UNKNOWN = 0; - MANDATORY = 1; - HINT = 2; - NONE = 3; + enum Utf8Validation { + UTF8_VALIDATION_UNKNOWN = 0; + NONE = 1; + VERIFY = 2; } - optional StringFieldValidation string_field_validation = 4 [ + optional Utf8Validation utf8_validation = 4 [ retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "MANDATORY" } + edition_defaults = { edition: EDITION_2023, value: "VERIFY" } ]; enum MessageEncoding { @@ -958,7 +976,7 @@ message FeatureSet { retention = RETENTION_RUNTIME, targets = TARGET_TYPE_FIELD, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "LENGTH_PREFIXED" } + edition_defaults = { edition: EDITION_2023, value: "LENGTH_PREFIXED" } ]; enum JsonFormat { @@ -971,10 +989,10 @@ message FeatureSet { targets = TARGET_TYPE_MESSAGE, targets = TARGET_TYPE_ENUM, targets = TARGET_TYPE_FILE, - edition_defaults = { edition: "2023", value: "ALLOW" } + edition_defaults = { edition: EDITION_2023, value: "ALLOW" } ]; - optional FeatureSet raw_features = 999 [targets = TARGET_TYPE_UNKNOWN]; + reserved 999; extensions 1000; // for Protobuf C++ extensions 1001; // for Protobuf Java @@ -982,6 +1000,30 @@ message FeatureSet { extensions 9995 to 9999; // For internal testing } +// A compiled specification for the defaults of a set of features. These +// messages are generated from FeatureSet extensions and can be used to seed +// feature resolution. The resolution with this object becomes a simple search +// for the closest matching edition, followed by proto merges. +message FeatureSetDefaults { + // A map from every known edition with a unique set of defaults to its + // defaults. Not all editions may be contained here. For a given edition, + // the defaults at the closest matching edition ordered at or before it should + // be used. This field must be in strict ascending order by edition. + message FeatureSetEditionDefault { + optional Edition edition = 3; + optional FeatureSet features = 2; + } + repeated FeatureSetEditionDefault defaults = 1; + + // The minimum supported edition (inclusive) when this was constructed. + // Editions before this will not have defaults. + optional Edition minimum_edition = 4; + + // The maximum known edition (inclusive) when this was constructed. Editions + // after this will not have reliable defaults. + optional Edition maximum_edition = 5; +} + // =================================================================== // Optional source code info diff --git a/dev/src/v1/firestore_admin_client.ts b/dev/src/v1/firestore_admin_client.ts index 9022e1fa4..e36f41ca5 100644 --- a/dev/src/v1/firestore_admin_client.ts +++ b/dev/src/v1/firestore_admin_client.ts @@ -123,8 +123,7 @@ export class FirestoreAdminClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you @@ -132,7 +131,7 @@ export class FirestoreAdminClient { * HTTP implementation. Load only fallback version and pass it to the constructor: * ``` * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreAdminClient({fallback: 'rest'}, gax); + * const client = new FirestoreAdminClient({fallback: true}, gax); * ``` */ constructor( @@ -202,7 +201,7 @@ export class FirestoreAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -256,7 +255,7 @@ export class FirestoreAdminClient { auth: this.auth, grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; - if (opts.fallback === 'rest') { + if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; lroOptions.httpRules = [ { diff --git a/dev/src/v1/firestore_client.ts b/dev/src/v1/firestore_client.ts index 1ad2a3a2b..277d98870 100644 --- a/dev/src/v1/firestore_client.ts +++ b/dev/src/v1/firestore_client.ts @@ -99,8 +99,7 @@ export class FirestoreClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you @@ -108,7 +107,7 @@ export class FirestoreClient { * HTTP implementation. Load only fallback version and pass it to the constructor: * ``` * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: 'rest'}, gax); + * const client = new FirestoreClient({fallback: true}, gax); * ``` */ constructor( @@ -178,7 +177,7 @@ export class FirestoreClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -213,23 +212,23 @@ export class FirestoreClient { this.descriptors.stream = { batchGetDocuments: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), runQuery: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), runAggregationQuery: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), write: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), listen: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), }; diff --git a/dev/src/v1beta1/firestore_client.ts b/dev/src/v1beta1/firestore_client.ts index 85c38e538..2ce99323e 100644 --- a/dev/src/v1beta1/firestore_client.ts +++ b/dev/src/v1beta1/firestore_client.ts @@ -99,8 +99,7 @@ export class FirestoreClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you @@ -108,7 +107,7 @@ export class FirestoreClient { * HTTP implementation. Load only fallback version and pass it to the constructor: * ``` * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: 'rest'}, gax); + * const client = new FirestoreClient({fallback: true}, gax); * ``` */ constructor( @@ -174,7 +173,7 @@ export class FirestoreClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest') { + } else { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -209,19 +208,19 @@ export class FirestoreClient { this.descriptors.stream = { batchGetDocuments: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), runQuery: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), write: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), listen: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.BIDI_STREAMING, - opts.fallback === 'rest' + !!opts.fallback ), }; 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 d4f03a0df..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 4eaf8d13d..000000000 --- a/owl-bot-staging/admin/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/admin/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/admin/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/admin/v1/package.json deleted file mode 100644 index 00c1a1a85..000000000 --- a/owl-bot-staging/admin/v1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.4" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.17", - "c8": "^8.0.1", - "gapic-tools": "^0.2.0", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^3.0.0", - "jsdoc-region-tag": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 5d9b762a1..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/database.proto +++ /dev/null @@ -1,129 +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.admin.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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. - // - // Mode changes are only allowed if the database is empty. - enum DatabaseType { - // The default value. This value is used if the database type is omitted. - DATABASE_TYPE_UNSPECIFIED = 0; - - // 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 mode is available - // for Cloud Firestore databases. - OPTIMISTIC = 1; - - // Use pessimistic concurrency control by default. This mode is available - // for Cloud Firestore databases. - // - // This is the default setting for Cloud Firestore. - PESSIMISTIC = 2; - - // Use optimistic concurrency control with entity groups by default. - // - // This is the only available mode for Cloud Datastore. - // - // This mode is also available for Cloud Firestore with Datastore Mode but - // is not recommended. - OPTIMISTIC_WITH_ENTITY_GROUPS = 3; - } - - // The type of App Engine integration mode. - enum AppEngineIntegrationMode { - // Not used. - APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; - - // If an App Engine application exists in the same region as this database, - // App Engine configuration will impact this database. This includes - // disabling of the application & database, as well as disabling writes to - // the database. - ENABLED = 1; - - // Appengine has no affect on the ability of this database to serve - // requests. - DISABLED = 2; - } - - // The resource name of the Database. - // Format: `projects/{project}/databases/{database}` - string name = 1; - - // 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; - - // The App Engine integration mode to use for this database. - AppEngineIntegrationMode app_engine_integration_mode = 19; - - // Output only. The key_prefix for this database. This key_prefix is used, in combination - // with the project id ("~") to construct the - // application id that is returned from the Cloud Datastore APIs in Google App - // Engine first generation runtimes. - // - // This value may be empty in which case the appid to use for URL-encoded keys - // is the project_id (eg: foo instead of v~foo). - string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // This checksum is computed by the server based on the value of other - // fields, and may be sent on update and delete requests to ensure the - // client has an up-to-date value before proceeding. - 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 5cd1cd481..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/field.proto +++ /dev/null @@ -1,136 +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.admin.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/firestore/admin/v1/index.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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; - } - - // The TTL (time-to-live) configuration for documents that have this `Field` - // set. - // Storing a timestamp value into a TTL-enabled field will be treated as - // the document's absolute expiration time. Using any other data type or - // leaving the field absent will disable the TTL for the individual document. - message TtlConfig { - // The state of applying the TTL configuration to all documents. - enum State { - // The state is unspecified or unknown. - STATE_UNSPECIFIED = 0; - - // The TTL is being applied. There is an active long-running operation to - // track the change. Newly written documents will have TTLs applied as - // requested. Requested TTLs on existing documents are still being - // processed. When TTLs on all existing documents have been processed, the - // state will move to 'ACTIVE'. - CREATING = 1; - - // The TTL is active for all documents. - ACTIVE = 2; - - // The TTL configuration could not be enabled for all existing documents. - // Newly written documents will continue to have their TTL applied. - // The LRO returned when last attempting to enable TTL for this `Field` - // has failed, and may have more details. - NEEDS_REPAIR = 3; - } - - // Output only. The state of the TTL configuration. - State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - } - - // Required. A field name of the form - // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` - // - // 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; - - // The TTL configuration for this `Field`. - // Setting or unsetting this will enable or disable the TTL for - // documents that have this `Field`. - TtlConfig ttl_config = 3; -} diff --git a/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 e1faa4dcf..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/firestore_admin.proto +++ /dev/null @@ -1,512 +0,0 @@ -// Copyright 2023 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/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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" - }; - } - - // Create a database. - rpc CreateDatabase(CreateDatabaseRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{parent=projects/*}/databases" - body: "database" - }; - option (google.api.method_signature) = "parent,database,database_id"; - option (google.longrunning.operation_info) = { - response_type: "Database" - metadata_type: "CreateDatabaseMetadata" - }; - } - - // 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 request for -// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]. -message CreateDatabaseRequest { - // 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" - } - ]; - - // Required. The Database to create. - Database database = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The ID to use for the database, which will become the final - // component of the database's resource name. - // - // The value must be set to "(default)". - string database_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Metadata related to the create database operation. -message CreateDatabaseMetadata {} - -// 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 2567da650..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/index.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2023 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"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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}" - }; - - // 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; - - // Include all the collections's ancestor in the index. Only available for - // Datastore Mode databases. - COLLECTION_RECURSIVE = 3; - } - - // API Scope defines the APIs (Firestore Native, or Firestore in - // Datastore Mode) that are supported for queries. - enum ApiScope { - // The index can only be used by the Firestore Native query API. - // This is the default. - ANY_API = 0; - - // The index can only be used by the Firestore in Datastore Mode query API. - DATASTORE_MODE_API = 1; - } - - // 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; - } - } - - // 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 API scope supported by this index. - ApiScope api_scope = 5; - - // The fields supported by this index. - // - // For composite indexes, this requires a minimum of 2 and a maximum of 100 - // 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 abf836d92..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/location.proto +++ /dev/null @@ -1,31 +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.admin.v1; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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 6b0562293..000000000 --- a/owl-bot-staging/admin/v1/protos/google/firestore/admin/v1/operation.proto +++ /dev/null @@ -1,223 +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.admin.v1; - -import "google/firestore/admin/v1/index.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; -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; - } - - // Information about an TTL configuration change. - message TtlConfigDelta { - // Specifies how the TTL config is changing. - enum ChangeType { - // The type of change is not specified or known. - CHANGE_TYPE_UNSPECIFIED = 0; - - // The TTL config is being added. - ADD = 1; - - // The TTL config is being removed. - REMOVE = 2; - } - - // Specifies how the TTL configuration is changing. - ChangeType change_type = 1; - } - - // The time this operation started. - google.protobuf.Timestamp start_time = 1; - - // 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; - - // Describes the deltas of TTL configuration. - TtlConfigDelta ttl_config_delta = 8; -} - -// 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_database.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js deleted file mode 100644 index 74fe712ca..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_database.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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, database, databaseId) { - // [START firestore_v1_generated_FirestoreAdmin_CreateDatabase_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A parent name of the form - * `projects/{project_id}` - */ - // const parent = 'abc123' - /** - * Required. The Database to create. - */ - // const database = {} - /** - * Required. The ID to use for the database, which will become the final - * component of the database's resource name. - * The value must be set to "(default)". - */ - // const databaseId = 'abc123' - - // Imports the Admin library - const {FirestoreAdminClient} = require('@google-cloud/firestore-admin').v1; - - // Instantiates a client - const adminClient = new FirestoreAdminClient(); - - async function callCreateDatabase() { - // Construct request - const request = { - parent, - database, - databaseId, - }; - - // Run request - const [operation] = await adminClient.createDatabase(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateDatabase(); - // [END firestore_v1_generated_FirestoreAdmin_CreateDatabase_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.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js deleted file mode 100644 index 0cf3b60d8..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.create_index.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 d4af852b5..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.delete_index.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 a678fbe55..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.export_documents.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 14fede7e8..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_database.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 f7de563b7..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_field.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 749a20bbf..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.get_index.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 5101ecbdc..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.import_documents.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 084fc96ef..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_databases.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 87d562fbe..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_fields.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 7c1e33448..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.list_indexes.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 cedf7f52a..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_database.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 3d1e1b72f..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/firestore_admin.update_field.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 96be9887a..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata_google.firestore.admin.v1.json +++ /dev/null @@ -1,595 +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": 60, - "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": 70, - "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": 54, - "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": 54, - "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": 54, - "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": 59, - "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": 75, - "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": 70, - "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": 68, - "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_CreateDatabase_async", - "title": "FirestoreAdmin createDatabase Sample", - "origin": "API_DEFINITION", - "description": " Create a database.", - "canonical": true, - "file": "firestore_admin.create_database.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "database", - "type": ".google.firestore.admin.v1.Database" - }, - { - "name": "database_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FirestoreAdminClient", - "fullName": "google.firestore.admin.v1.FirestoreAdminClient" - }, - "method": { - "shortName": "CreateDatabase", - "fullName": "google.firestore.admin.v1.FirestoreAdmin.CreateDatabase", - "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": 54, - "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": 54, - "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": 58, - "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 53e4b4753..000000000 --- a/owl-bot-staging/admin/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 2a34954cf..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client.ts +++ /dev/null @@ -1,2282 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -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'; -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}; - locationsClient: LocationsClient; - 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/main/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/1.1 REST mode. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreAdminClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // 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 { - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback) { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/databases/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/databases/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/databases/*}/operations',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 createDatabaseResponse = protoFilesRoot.lookup( - '.google.firestore.admin.v1.Database') as gax.protobuf.Type; - const createDatabaseMetadata = protoFilesRoot.lookup( - '.google.firestore.admin.v1.CreateDatabaseMetadata') 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)), - createDatabase: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createDatabaseResponse.decode.bind(createDatabaseResponse), - createDatabaseMetadata.decode.bind(createDatabaseMetadata)), - 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 = this._gaxModule.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', 'createDatabase', '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._opts.fallback - ); - - 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 {@link protos.google.firestore.admin.v1.Index|Index}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Field|Field}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.Database|Database}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.admin.v1.ListDatabasesResponse|ListDatabasesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listDatabases(request, options, callback); - } - -/** - * Creates a composite index. This returns a - * {@link protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a field configuration. Currently, field updates apply only to - * single field index configuration. However, calls to - * {@link protos.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 protos.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateField, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportDocuments, this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Create a database. - * - * @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 {google.firestore.admin.v1.Database} request.database - * Required. The Database to create. - * @param {string} request.databaseId - * Required. The ID to use for the database, which will become the final - * component of the database's resource name. - * - * The value must be set to "(default)". - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async - */ - createDatabase( - request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createDatabase( - request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createDatabase( - request?: protos.google.firestore.admin.v1.ICreateDatabaseRequest, - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDatabase(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createDatabase()`. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore_admin.create_database.js - * region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async - */ - async checkCreateDatabaseProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createDatabase, this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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' - ] = this._gaxModule.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * 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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatabase, this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.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 {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.admin.v1.Index|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists the field configuration and metadata for this database. - * - * Currently, - * {@link protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} - * only supports listing fields that have been explicitly overridden. To issue - * this query, call - * {@link protos.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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.admin.v1.Field|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @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 {@link google.cloud.location.Location | Location}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. 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.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- 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.locationsClient.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 ee5860dbc..000000000 --- a/owl-bot-staging/admin/v1/src/v1/firestore_admin_client_config.json +++ /dev/null @@ -1,92 +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" - }, - "CreateDatabase": { - "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 c2af7c470..000000000 --- a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,161 +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" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "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" - ] - }, - "CreateDatabase": { - "methods": [ - "createDatabase" - ] - }, - "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 37fe8fb3f..000000000 --- a/owl-bot-staging/admin/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 4bafec29c..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 ddf2067ee..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/admin/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 03b1d8fc7..000000000 --- a/owl-bot-staging/admin/v1/test/gapic_firestore_admin_v1.ts +++ /dev/null @@ -1,2821 +0,0 @@ -// Copyright 2023 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetIndexRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteIndex = stubSimpleCall(expectedResponse); - const [response] = await client.deleteIndex(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.DeleteIndexRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getField = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getField(request), expectedError); - const actualRequest = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetFieldRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatabase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.GetDatabaseRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatabases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatabases(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatabases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListDatabasesRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createIndex(request), expectedError); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateIndexRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createIndex(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIndex as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateField(request), expectedError); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateFieldRequest', ['field', 'name']); - request.field.name = defaultValue1; - const expectedHeaderRequestParams = `field.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateField = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateField(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateField as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ExportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.exportDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.exportDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ImportDocumentsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('createDatabase', () => { - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDatabase(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatabase = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDatabase( - 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); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDatabase 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.CreateDatabaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.CreateDatabaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateDatabaseProgress 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.checkCreateDatabaseProgress(''), 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDatabase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.UpdateDatabaseRequest', ['database', 'name']); - request.database.name = defaultValue1; - const expectedHeaderRequestParams = `database.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatabase = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDatabase(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatabase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listIndexes(request), expectedError); - const actualRequest = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListIndexesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFields = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFields(request), expectedError); - const actualRequest = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFields as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.admin.v1.ListFieldsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listFields.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new firestoreadminModule.v1.FirestoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - 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 d4f03a0df..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 16a892325..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 63195a564..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.4" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.17", - "c8": "^8.0.1", - "gapic-tools": "^0.2.0", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^3.0.0", - "jsdoc-region-tag": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto b/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto deleted file mode 100644 index 05fea5da9..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/aggregation_result.proto +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2023 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/document.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -option java_multiple_files = true; -option java_outer_classname = "AggregationResultProto"; -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"; - -// The result of a single bucket from a Firestore aggregation query. -// -// The keys of `aggregate_fields` are the same for all results in an aggregation -// query, unlike document queries which can have different fields present for -// each result. -message AggregationResult { - // The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. - // - // The key is the - // [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias] - // assigned to the aggregation function on input and the size of this map - // equals the number of aggregation functions in the query. - map aggregate_fields = 2; -} diff --git a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto b/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto deleted file mode 100644 index c00bb9c17..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/bloom_filter.proto +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -option java_multiple_files = true; -option java_outer_classname = "BloomFilterProto"; -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 sequence of bits, encoded in a byte array. -// -// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only -// exception is the last byte, which may store 8 _or fewer_ bits. The `padding` -// defines the number of bits of the last byte to be ignored as "padding". The -// values of these "padding" bits are unspecified and must be ignored. -// -// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. -// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. -// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. -// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. -// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. -// -// The "size" of a `BitSequence` (the number of bits it contains) is calculated -// by this formula: `(bitmap.length * 8) - padding`. -message BitSequence { - // The bytes that encode the bit sequence. - // May have a length of zero. - bytes bitmap = 1; - - // The number of bits of the last byte in `bitmap` to ignore as "padding". - // If the length of `bitmap` is zero, then this value must be `0`. - // Otherwise, this value must be between 0 and 7, inclusive. - int32 padding = 2; -} - -// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). -// -// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit -// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers -// using 2's complement encoding. -// -// These two hash values, named `h1` and `h2`, are then used to compute the -// `hash_count` hash values using the formula, starting at `i=0`: -// -// h(i) = h1 + (i * h2) -// -// These resulting values are then taken modulo the number of bits in the bloom -// filter to get the bits of the bloom filter to test for the given entry. -message BloomFilter { - // The bloom filter data. - BitSequence bits = 1; - - // The number of hashes used by the algorithm. - int32 hash_count = 2; -} 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 2a562aa6e..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/common.proto +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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. - // - // Firestore does not allow 3rd party auth requests to create read-write. - // transactions. - 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 must be a microsecond precision timestamp within the past one - // hour, or if Point-in-Time Recovery is enabled, can additionally be a - // whole minute timestamp within the past 7 days. - 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 795200498..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/document.proto +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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 a4447d167..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/firestore.proto +++ /dev/null @@ -1,1094 +0,0 @@ -// Copyright 2023 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/aggregation_result.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/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.Firestore.V1"; -option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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 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: "*" - } - }; - } - - // Runs an aggregation query. - // - // Rather than producing [Document][google.firestore.v1.Document] results like - // [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API - // allows running an aggregation to produce a series of - // [AggregationResult][google.firestore.v1.AggregationResult] server-side. - // - // High-Level Example: - // - // ``` - // -- Return the number of documents in table given a filter. - // SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); - // ``` - rpc RunAggregationQuery(RunAggregationQueryRequest) - returns (stream RunAggregationQueryResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery" - 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. This method is - // only available via gRPC or WebChannel (not REST). - rpc Write(stream WriteRequest) returns (stream WriteResponse) { - option (google.api.http) = { - post: "/v1/{database=projects/*/databases/*}/documents:write" - body: "*" - }; - } - - // Listens to changes. This method is only available via gRPC or WebChannel - // (not REST). - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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]; - - // Optional. The collection ID, relative to `parent`, to list. - // - // For example: `chatrooms` or `messages`. - // - // This is optional, and when not provided, Firestore will list documents - // from all collections under the provided `parent`. - string collection_id = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of documents to return in a single response. - // - // Firestore may return fewer than this value. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A page token, received from a previous `ListDocuments` response. - // - // Provide this to retrieve the subsequent page. When paginating, all other - // parameters (with the exception of `page_size`) must match the values set - // in the request that generated the page token. - string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The optional ordering of the documents to return. - // - // For example: `priority desc, __name__ desc`. - // - // This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by] - // used in Firestore queries but in a string representation. When absent, - // documents are ordered based on `__name__ ASC`. - string order_by = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. 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 [(google.api.field_behavior) = OPTIONAL]; - - // The consistency mode for this transaction. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Perform the read as part of an already active transaction. - bytes transaction = 8; - - // Perform the read at the provided time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 10; - } - - // If the list should show missing documents. - // - // A document is missing if it does not exist, but there are sub-documents - // nested underneath it. When true, such missing documents will be returned - // with a key but will not have fields, - // [`create_time`][google.firestore.v1.Document.create_time], or - // [`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; - - // A token to retrieve the next page of documents. - // - // If this field is omitted, there are no subsequent pages. - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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 must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - 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.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. -message RunAggregationQueryRequest { - // 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 { - // An aggregation query. - StructuredAggregationQuery structured_aggregation_query = 2; - } - - // The consistency mode for the query, defaults to strong consistency. - oneof consistency_selector { - // Run the aggregation within an already active transaction. - // - // The value here is the opaque transaction ID to execute the query in. - bytes transaction = 4; - - // Starts a new transaction as part of the query, defaulting to read-only. - // - // The new transaction ID will be returned as the first response in the - // stream. - TransactionOptions new_transaction = 5; - - // Executes the query at the given timestamp. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 6; - } -} - -// The response for -// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. -message RunAggregationQueryResponse { - // A single aggregation result. - // - // Not present when reporting partial progress. - AggregationResult result = 1; - - // The transaction that was started as part of this request. - // - // Only present on the first response when the request requested to start - // a new transaction. - bytes transaction = 2; - - // The time at which the aggregate result was computed. This is always - // monotonically increasing; in this case, the previous AggregationResult 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 - // `result` will be sent, and this represents the time at which the query - // was run. - google.protobuf.Timestamp read_time = 3; -} - -// 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 consistency mode for this request. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents as they were at the given time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 6; - } -} - -// 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 specified, only the matching Documents that have been updated AFTER the - // `resume_token` or `read_time` will be returned. Otherwise, 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; - - // The number of documents that last matched the query at the resume token or - // read time. - // - // This value is only relevant when a `resume_type` is provided. This value - // being present and greater than zero signals that the client wants - // `ExistenceFilter.unchanged_names` to be included in the response. - google.protobuf.Int32Value expected_count = 12; -} - -// 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 consistency mode for this request. - // If not set, defaults to strong consistency. - oneof consistency_selector { - // Reads documents as they were at the given time. - // - // This must be a microsecond precision timestamp within the past one hour, - // or if Point-in-Time Recovery is enabled, can additionally be a whole - // minute timestamp within the past 7 days. - google.protobuf.Timestamp read_time = 4; - } -} - -// 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 4a4919634..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/query.proto +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright 2023 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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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; - - // Documents are required to satisfy at least one of the combined filters. - OR = 2; - } - - // 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`, subject to disjunction - // limits. - // * No `NOT_IN` filters in the same query. - 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`, subject to disjunction - // limits. - // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction. - // * No `NOT_IN` filters in the same query. - 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 `OR`, `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 in a document, ex: `stats.operations`. - message FieldReference { - // The relative path of the document being referenced. - // - // Requires: - // - // * Conform to [document field name][google.firestore.v1.Document.fields] - // limitations. - 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; - } - - // Optional sub-set of the fields to return. - // - // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the - // documents returned from a query. When not set, assumes that the caller - // wants all fields returned. - 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 allows callers to provide a full ordering, a partial ordering, or - // no ordering at all. In all cases, Firestore guarantees a stable ordering - // through the following rules: - // - // * The `order_by` is required to reference all fields used with an - // inequality filter. - // * All fields that are required to be in the `order_by` but are not already - // present are appended in lexicographical ordering of the field name. - // * 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: - // - // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` - // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` - // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` - // * `WHERE __name__ > ... AND a > 1` becomes - // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC` - repeated Order order_by = 4; - - // A potential prefix of a position in the result set to start the query at. - // - // The ordering of the result set is based on the `ORDER BY` clause of the - // original query. - // - // ``` - // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; - // ``` - // - // This query's results are ordered by `(b ASC, __name__ ASC)`. - // - // Cursors can reference either the full ordering or a prefix of the location, - // though it cannot reference more fields than what are in the provided - // `ORDER BY`. - // - // Continuing off the example above, attaching the following start cursors - // will have varying impact: - // - // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND - // b > 2 AND __name__ > /k/123`. - // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. - // - // Unlike `OFFSET` which requires scanning over the first N results to skip, - // a start cursor allows the query to begin at a logical position. This - // position is not required to match an actual result, it will scan forward - // from this position to find the next document. - // - // Requires: - // - // * The number of values cannot be greater than the number of fields - // specified in the `ORDER BY` clause. - Cursor start_at = 7; - - // A potential prefix of a position in the result set to end the query at. - // - // This is similar to `START_AT` but with it controlling the end position - // rather than the start position. - // - // Requires: - // - // * The number of values cannot be greater than the number of fields - // specified in the `ORDER BY` clause. - Cursor end_at = 8; - - // The number of documents to skip before returning the first result. - // - // This applies after the constraints specified by the `WHERE`, `START AT`, & - // `END AT` but before the `LIMIT` clause. - // - // Requires: - // - // * The value must be greater than or equal to zero if specified. - int32 offset = 6; - - // The maximum number of results to return. - // - // Applies after all other constraints. - // - // Requires: - // - // * The value must be greater than or equal to zero if specified. - google.protobuf.Int32Value limit = 5; -} - -// Firestore query for running an aggregation over a -// [StructuredQuery][google.firestore.v1.StructuredQuery]. -message StructuredAggregationQuery { - // Defines an aggregation that produces a single result. - message Aggregation { - // Count of documents that match the query. - // - // The `COUNT(*)` aggregation function operates on the entire document - // so it does not require a field reference. - message Count { - // Optional. Optional constraint on the maximum number of documents to - // count. - // - // This provides a way to set an upper bound on the number of documents - // to scan, limiting latency, and cost. - // - // Unspecified is interpreted as no bound. - // - // High-Level Example: - // - // ``` - // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); - // ``` - // - // Requires: - // - // * Must be greater than zero when present. - google.protobuf.Int64Value up_to = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Sum of the values of the requested field. - // - // * Only numeric values will be aggregated. All non-numeric values - // including `NULL` are skipped. - // - // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math - // follows IEEE-754 standards. - // - // * If the aggregated value set is empty, returns 0. - // - // * Returns a 64-bit integer if all aggregated numbers are integers and the - // sum result does not overflow. Otherwise, the result is returned as a - // double. Note that even if all the aggregated values are integers, the - // result is returned as a double if it cannot fit within a 64-bit signed - // integer. When this occurs, the returned value will lose precision. - // - // * When underflow occurs, floating-point aggregation is non-deterministic. - // This means that running the same query repeatedly without any changes to - // the underlying values could produce slightly different results each - // time. In those cases, values should be stored as integers over - // floating-point numbers. - message Sum { - // The field to aggregate on. - StructuredQuery.FieldReference field = 1; - } - - // Average of the values of the requested field. - // - // * Only numeric values will be aggregated. All non-numeric values - // including `NULL` are skipped. - // - // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math - // follows IEEE-754 standards. - // - // * If the aggregated value set is empty, returns `NULL`. - // - // * Always returns the result as a double. - message Avg { - // The field to aggregate on. - StructuredQuery.FieldReference field = 1; - } - - // The type of aggregation to perform, required. - oneof operator { - // Count aggregator. - Count count = 1; - - // Sum aggregator. - Sum sum = 2; - - // Average aggregator. - Avg avg = 3; - } - - // Optional. Optional name of the field to store the result of the - // aggregation into. - // - // If not provided, Firestore will pick a default name following the format - // `field_`. For example: - // - // ``` - // AGGREGATE - // COUNT_UP_TO(1) AS count_up_to_1, - // COUNT_UP_TO(2), - // COUNT_UP_TO(3) AS count_up_to_3, - // COUNT(*) - // OVER ( - // ... - // ); - // ``` - // - // becomes: - // - // ``` - // AGGREGATE - // COUNT_UP_TO(1) AS count_up_to_1, - // COUNT_UP_TO(2) AS field_1, - // COUNT_UP_TO(3) AS count_up_to_3, - // COUNT(*) AS field_2 - // OVER ( - // ... - // ); - // ``` - // - // Requires: - // - // * Must be unique across all aggregation aliases. - // * Conform to [document field name][google.firestore.v1.Document.fields] - // limitations. - string alias = 7 [(google.api.field_behavior) = OPTIONAL]; - } - - // The base query to aggregate over. - oneof query_type { - // Nested structured query. - StructuredQuery structured_query = 1; - } - - // Optional. Series of aggregations to apply over the results of the - // `structured_query`. - // - // Requires: - // - // * A minimum of one and maximum of five aggregations per query. - repeated Aggregation aggregations = 3 - [(google.api.field_behavior) = OPTIONAL]; -} - -// 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 4b46595ce..000000000 --- a/owl-bot-staging/v1/protos/google/firestore/v1/write.proto +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright 2023 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/bloom_filter.proto"; -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 = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; -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. - // - // The client can use the `unchanged_names` bloom filter to assist with - // this determination by testing ALL the document names against the filter; - // if the document name is NOT in the filter, it means the document no - // longer matches the target. - int32 count = 2; - - // A bloom filter that, despite its name, contains the UTF-8 byte encodings of - // the resource names of ALL the documents that match - // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form - // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. - // - // This bloom filter may be omitted at the server's discretion, such as if it - // is deemed that the client will not make use of it or if it is too - // computationally expensive to calculate or transmit. Clients must gracefully - // handle this field being absent by falling back to the logic used before - // this field existed; that is, re-add the target without a resume token to - // figure out which documents in the client's cache are out of sync. - BloomFilter unchanged_names = 3; -} 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 d1be99f6f..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_get_documents.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 2180becfe..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.batch_write.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * Labels associated with this batch write. - */ - // const labels = [1,2,3,4] - - // 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 fe03086ab..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.begin_transaction.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 70f3ba056..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.commit.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 0d1894891..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.create_document.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 bbb97ac7d..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.delete_document.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 93ad08cc9..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.get_document.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 463d68372..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_collection_ids.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Reads documents as they were at the given time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // 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 a271d2fa3..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.list_documents.js +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2023 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_ListDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Optional. The collection ID, relative to `parent`, to list. - * For example: `chatrooms` or `messages`. - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - */ - // const collectionId = 'abc123' - /** - * Optional. The maximum number of documents to return in a single response. - * Firestore may return fewer than this value. - */ - // const pageSize = 1234 - /** - * Optional. A page token, received from a previous `ListDocuments` response. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - */ - // const pageToken = 'abc123' - /** - * Optional. The optional ordering of the documents to return. - * For example: `priority desc, __name__ desc`. - * This mirrors the `ORDER BY` google.firestore.v1.StructuredQuery.order_by - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - */ - // const orderBy = 'abc123' - /** - * Optional. 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 = {} - /** - * Perform the read as part of an already active transaction. - */ - // const transaction = Buffer.from('string') - /** - * Perform the read at the provided time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - /** - * If the list should show missing documents. - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * `create_time` google.firestore.v1.Document.create_time, or - * `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, - }; - - // 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 8b38795d5..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.listen.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - - // 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 84acded1b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.partition_query.js +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 - /** - * Reads documents as they were at the given time. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // 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 0c75482d1..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.rollback.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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_aggregation_query.js b/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js deleted file mode 100644 index 4e3d4f025..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.run_aggregation_query.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2023 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_RunAggregationQuery_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * An aggregation query. - */ - // const structuredAggregationQuery = {} - /** - * Run the aggregation 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 as part of the query, defaulting to read-only. - * The new transaction ID will be returned as the first response in the - * stream. - */ - // const newTransaction = {} - /** - * Executes the query at the given timestamp. - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // const readTime = {} - - // Imports the Firestore library - const {FirestoreClient} = require('@google-cloud/firestore').v1; - - // Instantiates a client - const firestoreClient = new FirestoreClient(); - - async function callRunAggregationQuery() { - // Construct request - const request = { - parent, - }; - - // Run request - const stream = await firestoreClient.runAggregationQuery(request); - stream.on('data', (response) => { console.log(response) }); - stream.on('error', (err) => { throw(err) }); - stream.on('end', () => { /* API call completed */ }); - } - - callRunAggregationQuery(); - // [END firestore_v1_generated_Firestore_RunAggregationQuery_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 2717ffa3b..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.run_query.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - */ - // 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 904a7cd3a..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.update_document.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 8cfd43d15..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/firestore.write.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 321061a5c..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata_google.firestore.v1.json +++ /dev/null @@ -1,867 +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": 71, - "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": 114, - "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": 74, - "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": 59, - "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": 87, - "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": 59, - "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": 63, - "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": 59, - "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": 83, - "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_RunAggregationQuery_async", - "title": "Firestore runAggregationQuery Sample", - "origin": "API_DEFINITION", - "description": " Runs an aggregation query. Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side. High-Level Example: ``` -- Return the number of documents in table given a filter. SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); ```", - "canonical": true, - "file": "firestore.run_aggregation_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 82, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunAggregationQuery", - "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "structured_aggregation_query", - "type": ".google.firestore.v1.StructuredAggregationQuery" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "new_transaction", - "type": ".google.firestore.v1.TransactionOptions" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "resultType": ".google.firestore.v1.RunAggregationQueryResponse", - "client": { - "shortName": "FirestoreClient", - "fullName": "google.firestore.v1.FirestoreClient" - }, - "method": { - "shortName": "RunAggregationQuery", - "fullName": "google.firestore.v1.Firestore.RunAggregationQuery", - "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": 104, - "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" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "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. This method is only available via gRPC or WebChannel (not REST).", - "canonical": true, - "file": "firestore.write.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 90, - "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. This method is only available via gRPC or WebChannel (not REST).", - "canonical": true, - "file": "firestore.listen.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "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": 74, - "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" - }, - { - "name": "read_time", - "type": ".google.protobuf.Timestamp" - } - ], - "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": 65, - "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": 77, - "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 30d0870ac..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 93b2a5294..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client.ts +++ /dev/null @@ -1,2118 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform, 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 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}; - locationsClient: LocationsClient; - 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/main/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/1.1 REST mode. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // 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 { - 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(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), - runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), - runAggregationQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), - write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback), - listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback) - }; - - // 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 = this._gaxModule.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', 'runAggregationQuery', '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 this._gaxModule.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._opts.fallback - ); - - 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.BeginTransactionResponse|BeginTransactionResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.CommitResponse|CommitResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the - * success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link protos.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 {@link protos.google.firestore.v1.BatchWriteResponse|BatchWriteResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.RunQueryResponse|RunQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.runQuery(request, options); - } - -/** - * Runs an aggregation query. - * - * Rather than producing {@link protos.google.firestore.v1.Document|Document} results like - * {@link protos.google.firestore.v1.Firestore.RunQuery|Firestore.RunQuery}, this API - * allows running an aggregation to produce a series of - * {@link protos.google.firestore.v1.AggregationResult|AggregationResult} server-side. - * - * High-Level Example: - * - * ``` - * -- Return the number of documents in table given a filter. - * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); - * ``` - * - * @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.StructuredAggregationQuery} request.structuredAggregationQuery - * An aggregation query. - * @param {Buffer} request.transaction - * Run the aggregation 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 as part of the query, defaulting to read-only. - * - * The new transaction ID will be returned as the first response in the - * stream. - * @param {google.protobuf.Timestamp} request.readTime - * Executes the query at the given timestamp. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * for more details and examples. - * @example include:samples/generated/v1/firestore.run_aggregation_query.js - * region_tag:firestore_v1_generated_Firestore_RunAggregationQuery_async - */ - runAggregationQuery( - request?: protos.google.firestore.v1.IRunAggregationQueryRequest, - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.runAggregationQuery(request, options); - } - -/** - * Streams batches of document updates and deletes, in order. This method is - * only available via gRPC or WebChannel (not REST). - * - * @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 {@link protos.google.firestore.v1.WriteRequest|WriteRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1.WriteResponse|WriteResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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. This method is only available via gRPC or WebChannel - * (not REST). - * - * @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 {@link protos.google.firestore.v1.ListenRequest|ListenRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1.ListenResponse|ListenResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as 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] - * Optional. The collection ID, relative to `parent`, to list. - * - * For example: `chatrooms` or `messages`. - * - * This is optional, and when not provided, Firestore will list documents - * from all collections under the provided `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of documents to return in a single response. - * - * Firestore may return fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListDocuments` response. - * - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters (with the exception of `page_size`) must match the values set - * in the request that generated the page token. - * @param {string} [request.orderBy] - * Optional. The optional ordering of the documents to return. - * - * For example: `priority desc, __name__ desc`. - * - * This mirrors the {@link protos.google.firestore.v1.StructuredQuery.order_by|`ORDER BY`} - * used in Firestore queries but in a string representation. When absent, - * documents are ordered based on `__name__ ASC`. - * @param {google.firestore.v1.DocumentMask} [request.mask] - * Optional. 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 - * Perform the read as part of an already active transaction. - * @param {google.protobuf.Timestamp} request.readTime - * Perform the read at the provided time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @param {boolean} request.showMissing - * If the list should show missing documents. - * - * A document is missing if it does not exist, but there are sub-documents - * nested underneath it. When true, such missing documents will be returned - * with a key but will not have fields, - * {@link protos.google.firestore.v1.Document.create_time|`create_time`}, or - * {@link protos.google.firestore.v1.Document.update_time|`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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {}, - 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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}. - * @param {google.protobuf.Timestamp} request.readTime - * Reads documents as they were at the given time. - * - * This must be a microsecond precision timestamp within the past one hour, - * or if Point-in-Time Recovery is enabled, can additionally be a whole - * minute timestamp within the past 7 days. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @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 {@link google.cloud.location.Location | Location}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. 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.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - - - /** - * 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(); - this.locationsClient.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 75487fc9b..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_client_config.json +++ /dev/null @@ -1,121 +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" - }, - "RunAggregationQuery": { - "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 5c2cd76e2..000000000 --- a/owl-bot-staging/v1/src/v1/firestore_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/firestore/v1/aggregation_result.proto", - "../../protos/google/firestore/v1/bloom_filter.proto", - "../../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 4fce00187..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,170 +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" - ] - }, - "RunAggregationQuery": { - "methods": [ - "runAggregationQuery" - ] - }, - "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 aac58c1b4..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 75ce02186..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 7d85b1cb7..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 598cb8f24..000000000 --- a/owl-bot-staging/v1/test/gapic_firestore_v1.ts +++ /dev/null @@ -1,2423 +0,0 @@ -// Copyright 2023 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.BeginTransactionResponse() - ); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CommitRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RollbackRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.BatchWriteResponse() - ); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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('runAggregationQuery', () => { - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1.RunAggregationQueryResponse() - ); - client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(expectedResponse); - const stream = client.runAggregationQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.runAggregationQuery = stubServerStreamingCall(undefined, expectedError); - const stream = client.runAggregationQuery(request); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - const actualRequest = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runAggregationQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runAggregationQuery 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.RunAggregationQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.RunAggregationQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runAggregationQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.firestore.v1.RunAggregationQueryResponse) => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation 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 LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new firestoreModule.v1.FirestoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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 d4f03a0df..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 830c28c2c..000000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 2023 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 1a38f257d..000000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 55639e70f..000000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 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/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index 2240d9b31..000000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,58 +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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "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": "^4.0.4" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.17", - "c8": "^8.0.1", - "gapic-tools": "^0.2.0", - "gts": "5.0.1", - "jsdoc": "^4.0.2", - "jsdoc-fresh": "^3.0.0", - "jsdoc-region-tag": "^3.0.0", - "mocha": "^10.2.0", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.2.0", - "typescript": "5.1.6" - }, - "engines": { - "node": ">=v14" - } -} 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 1a18c41bc..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/common.proto +++ /dev/null @@ -1,82 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 de192806d..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/document.proto +++ /dev/null @@ -1,149 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 047f029e4..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 = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 7d7ef11ce..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/query.proto +++ /dev/null @@ -1,300 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 124526a59..000000000 --- a/owl-bot-staging/v1beta1/protos/google/firestore/v1beta1/write.proto +++ /dev/null @@ -1,258 +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"; - -option csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; -option go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; -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 83d1138bc..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_get_documents.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = ['abc','def'] - /** - * 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 0e33ee732..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.batch_write.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * Labels associated with this batch write. - */ - // const labels = [1,2,3,4] - - // 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 f07a8e5f1..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.begin_transaction.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 9fa52db04..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.commit.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 d1b6ef3f7..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.create_document.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 01e5417dd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.delete_document.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 ca4c8dcfd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.get_document.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 5d262fe3c..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_collection_ids.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 ae64fb980..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.list_documents.js +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 9a9e2b838..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.listen.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - - // 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 808ef53d7..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.partition_query.js +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 7041957dd..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.rollback.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 3fd93dada..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.run_query.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 dac3b53dc..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.update_document.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 928b5c292..000000000 --- a/owl-bot-staging/v1beta1/samples/generated/v1beta1/firestore.write.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 = [1,2,3,4] - /** - * 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 = [1,2,3,4] - - // 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 e585b9cfb..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": 69, - "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": 102, - "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": 74, - "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": 59, - "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": 85, - "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": 59, - "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": 63, - "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": 59, - "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": 80, - "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": 97, - "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": 90, - "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": 70, - "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": 67, - "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": 65, - "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": 76, - "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 1ef09ee45..000000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 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 0e3285761..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/firestore_client.ts +++ /dev/null @@ -1,1848 +0,0 @@ -// Copyright 2023 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 type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform, 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/main/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/1.1 REST mode. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new FirestoreClient({fallback: true}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // 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; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // 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 { - 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(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), - runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback), - write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback), - listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback) - }; - - // 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 = this._gaxModule.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 this._gaxModule.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._opts.fallback - ); - - 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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.BeginTransactionResponse|BeginTransactionResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.CommitResponse|CommitResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.protobuf.Empty|Empty}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse} for the success status of each write. - * - * If you require an atomically applied set of writes, use - * {@link protos.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 {@link protos.google.firestore.v1beta1.BatchWriteResponse|BatchWriteResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Document|Document}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {@link protos.google.firestore.v1beta1.BatchGetDocumentsResponse|BatchGetDocumentsResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.RunQueryResponse|RunQueryResponse} on 'data' event. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.WriteRequest|WriteRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1beta1.WriteResponse|WriteResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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 {@link protos.google.firestore.v1beta1.ListenRequest|ListenRequest} for write() method, and - * will emit objects representing {@link protos.google.firestore.v1beta1.ListenResponse|ListenResponse} on 'data' event asynchronously. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming | documentation } - * 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - const defaultCallSettings = this._defaults['listDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocuments.createStream( - this.innerApiCalls.listDocuments as 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 protos.google.firestore.v1beta1.Document.create_time|Document.create_time}, - * or {@link protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1beta1.Document|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - 'collection_id': request.collectionId ?? '', - }); - 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 {}, - 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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.firestore.v1beta1.Cursor|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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 protos.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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 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 protos.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 {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * 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 {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * 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' - ] = this._gaxModule.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 {}, - 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 aac58c1b4..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 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 3dd1ef017..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 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 08f759d2b..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 c8f81b25a..000000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 b7fa1695c..000000000 --- a/owl-bot-staging/v1beta1/test/gapic_firestore_v1beta1.ts +++ /dev/null @@ -1,2160 +0,0 @@ -// Copyright 2023 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'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - const expectedHeaderRequestParams = `document.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.UpdateDocumentRequest', ['document', 'name']); - request.document.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.BeginTransactionResponse() - ); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - const actualRequest = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BeginTransactionRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.CommitResponse() - ); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - const actualRequest = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.commit as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CommitRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - const actualRequest = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rollback as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RollbackRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.BatchWriteResponse() - ); - client.innerApiCalls.batchWrite = stubSimpleCall(expectedResponse); - const [response] = await client.batchWrite(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchWrite = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchWrite(request), expectedError); - const actualRequest = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchWrite as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchWriteRequest', ['database']); - request.database = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedResponse = generateSampleMessage( - new protos.google.firestore.v1beta1.Document() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.CreateDocumentRequest', ['collectionId']); - request.collectionId = defaultValue2; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedHeaderRequestParams = `database=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchGetDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.BatchGetDocumentsRequest', ['database']); - request.database = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.batchGetDocuments(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.RunQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - const stream = client.runQuery(request, {retryRequestOptions: {noResponseRetries: 0}}); - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`;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); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.firestore.v1beta1.ListDocumentsRequest', ['collectionId']); - request.collectionId = defaultValue2; - const expectedHeaderRequestParams = `parent=${defaultValue1}&collection_id=${defaultValue2}`; - 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( - (client.descriptors.page.listDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.partitionQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.partitionQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.partitionQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.PartitionQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.partitionQuery.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.listCollectionIds = stubSimpleCall(expectedResponse); - const [response] = await client.listCollectionIds(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCollectionIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCollectionIds(request), expectedError); - const actualRequest = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCollectionIds as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.firestore.v1beta1.ListCollectionIdsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCollectionIds.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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', -};